Program Design — Lab 3
Deadline: April 9th, 2026 at 3:00 p.m.
A. Exam Score Analysis
After the midterm exam, the professor wants a quick summary of the class
performance. Consider the following input file [Link] :
9
72
88
95
60
73
85
91
78
66
The first line is an integer indicating the number of students n (1 < n < 10000).
The subsequent n lines are exam scores (integers, 0–100).
Write a C++ program to read [Link] and write the following to [Link] :
95
11.22
78.67
Where:
Line 1: the highest score (integer)
Line 2: the population standard deviation, to 2 decimal places, defined as:
1
σ= n
∑ni=1 (xi − x
ˉ )2
where xˉ is the average score
Line 3: the average score, to 2 decimal places
Program Design — Lab 3 1
Use vector from the lecture to finish it.
Class Design
You must implement a class Score to handle the data and computations. The
following data types should be used:
Scores read from file should be stored as int
The highest score should be returned as int
The standard deviation and average should be returned as double
The output formatting and writing to [Link] should be handled in main() using
ofstream , fixed , and setprecision(2) from <iomanip> .
B. Sorting Performance
Copy the program from pages 30 and 31 in slides "Array_Vector." Modify and
run experiments with different size values: 1000, 10000, and 100000.
Note: insertion_sort() may take a very long time for large inputs. Be patient,
or terminate early and note the estimated time in your README.
Use the class from the lecture (pages 30–31). Place the class definition in
Clock
Clock.h and its implementation in [Link] .
Record your results and explanation in the README file. For each experiment,
note the size, algorithm, and measured runtime. Use the results to explain the
difference between O(n log n) and O(n²).
Hand-in Rules
File Hierarchy
<StudentID>.zip
└── lab3/
├── lab3_a/
│ ├── lab3_a.cpp
│ ├── Score.h
│ ├── [Link]
│ ├── [Link]
│ ├── [Link]
Program Design — Lab 3 2
│ ├── Makefile
│ └── README
└── lab3_b/
├── lab3_b.cpp
├── Clock.h
├── [Link]
├── Makefile
└── README
Example for a student with ID E14123456 :
[Link]
└── lab3/
├── lab3_a/
│ ├── lab3_a.cpp
│ ├── Score.h
│ ├── [Link]
│ ├── [Link]
│ ├── [Link]
│ ├── Makefile
│ └── README
└── lab3_b/
├── lab3_b.cpp
├── Clock.h
├── [Link]
├── Makefile
└── README
Makefile Templates
Both lab3_a and lab3_b include a Makefile with placeholders for you to fill in.
lab3_a/Makefile:
lab3_a: lab3_a.o Score.o
g++ -o <executable> <object files...>
lab3_a.o: lab3_a.cpp Score.h
g++ -c <source file>
Score.o: [Link] Score.h
Program Design — Lab 3 3
g++ -c <source file>
clean:
rm -f <files to remove>
lab3_b/Makefile:
lab3_b: lab3_b.o Clock.o
g++ -o <executable> <object files...>
lab3_b.o: lab3_b.cpp Clock.h
g++ -c <source file>
Clock.o: [Link] Clock.h
g++ -c <source file>
clean:
rm -f <files to remove>
Note: The indentation before each g++ command must be a Tab character,
not spaces.
README
lab3_a/README : Describe how to compile and run your program.
lab3_b/README: Describe how to compile and run your program. Record the
size, algorithm, and measured runtime for each experiment, and explain
why sort() is significantly faster than insertion_sort() for large inputs.
Submission Rules
1. Name your zip file <StudentID>.zip and place all files under lab3/lab3_a/ and
lab3/lab3_b/ respectively.
2. lab3_a.cpp and lab3_b.cpp must be the main entry points for each question.
3. You may add additional .cpp or .h files as needed.
4. Upload the zip file to Moodle before the deadline (April 9th, 2026 at 3:00
p.m.).
5. Do not include executable files or object files ( .o , .out , .exe ).
Program Design — Lab 3 4