Skip to content

Commit 9329888

Browse files
committed
Add module runner scripts and level assessments
1 parent 8e8c776 commit 9329888

9 files changed

Lines changed: 453 additions & 2 deletions

File tree

README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ Python parity starter modules live in `languages/python/01-foundations`:
5252
- follow the level order from foundations to expert
5353
4. Mark progress in `languages/cpp/CHECKLIST.md`
5454
5. Build capstones in `languages/cpp/projects/`
55-
6. Follow weekly pacing in `STUDY_PLAN.md`
55+
6. Complete level assessments in `languages/cpp/assessments/`
56+
7. Follow weekly pacing in `STUDY_PLAN.md`
5657

5758
## Compile And Run (C++17)
5859

@@ -101,7 +102,21 @@ Bash:
101102
bash ./scripts/build-all.sh
102103
```
103104

104-
Both scripts compile each `*.cpp` file under `languages/cpp` with:
105+
Run a single module example quickly:
106+
107+
PowerShell:
108+
109+
```powershell
110+
./scripts/run-module.ps1 languages/cpp/01-foundations/strings
111+
```
112+
113+
Bash:
114+
115+
```bash
116+
bash ./scripts/run-module.sh languages/cpp/01-foundations/strings
117+
```
118+
119+
`build-all` compiles each `*.cpp` file under `languages/cpp` with:
105120

106121
```bash
107122
g++ -std=c++17 -Wall -Wextra -pedantic

languages/cpp/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ Use capstones to combine concepts in a realistic task flow:
8181

8282
- [projects/README.md](./projects/README.md)
8383

84+
## Level Assessments
85+
86+
Use assessments after each level to validate readiness before moving on:
87+
88+
- [assessments/README.md](./assessments/README.md)
89+
8490
## Hint Guides
8591

8692
- [01-foundations/HINTS.md](./01-foundations/HINTS.md)
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Assessment 01: Foundations
2+
3+
## Goal
4+
5+
Build confidence with input handling, loops, functions, vectors, and strings.
6+
7+
## Task
8+
9+
Write a program that:
10+
11+
1. Reads an integer `N` (`N > 0`).
12+
2. Reads `N` full names and exam scores (`0..100`).
13+
3. Prints:
14+
- all records
15+
- average score
16+
- highest score with student name
17+
- lowest score with student name
18+
- pass count (`score >= 60`)
19+
20+
## Quick Run
21+
22+
```bash
23+
g++ -std=c++17 -Wall -Wextra -pedantic main.cpp -o assessment_01_foundations
24+
./assessment_01_foundations
25+
```
26+
27+
## Sample Input
28+
29+
```text
30+
3
31+
Ana Smith
32+
91
33+
Bob Lee
34+
55
35+
Carla Mendez
36+
88
37+
```
38+
39+
## Sample Output (shape)
40+
41+
```text
42+
Students:
43+
- Ana Smith: 91
44+
- Bob Lee: 55
45+
- Carla Mendez: 88
46+
Average: 78
47+
Highest: Ana Smith (91)
48+
Lowest: Bob Lee (55)
49+
Passed: 2/3
50+
```
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
#include <iostream>
2+
#include <limits>
3+
#include <string>
4+
#include <vector>
5+
6+
using namespace std;
7+
8+
struct Student {
9+
string name;
10+
int score;
11+
};
12+
13+
int readPositiveCount() {
14+
int count = 0;
15+
while (true) {
16+
cout << "How many students? ";
17+
if (!(cin >> count)) {
18+
cout << "Invalid number. Try again.\n";
19+
cin.clear();
20+
cin.ignore(numeric_limits<streamsize>::max(), '\n');
21+
continue;
22+
}
23+
if (count <= 0) {
24+
cout << "Please enter a positive number.\n";
25+
cin.ignore(numeric_limits<streamsize>::max(), '\n');
26+
continue;
27+
}
28+
29+
cin.ignore(numeric_limits<streamsize>::max(), '\n');
30+
return count;
31+
}
32+
}
33+
34+
int readScore(const string& studentName) {
35+
int score = 0;
36+
while (true) {
37+
cout << "Score for " << studentName << " (0-100): ";
38+
if (!(cin >> score)) {
39+
cout << "Invalid score. Enter a number from 0 to 100.\n";
40+
cin.clear();
41+
cin.ignore(numeric_limits<streamsize>::max(), '\n');
42+
continue;
43+
}
44+
if (score < 0 || score > 100) {
45+
cout << "Score out of range. Enter a value from 0 to 100.\n";
46+
cin.ignore(numeric_limits<streamsize>::max(), '\n');
47+
continue;
48+
}
49+
50+
cin.ignore(numeric_limits<streamsize>::max(), '\n');
51+
return score;
52+
}
53+
}
54+
55+
int main() {
56+
const int count = readPositiveCount();
57+
vector<Student> students;
58+
students.reserve(static_cast<size_t>(count));
59+
60+
for (int i = 0; i < count; ++i) {
61+
Student student;
62+
cout << "Student name " << (i + 1) << ": ";
63+
getline(cin, student.name);
64+
student.score = readScore(student.name);
65+
students.push_back(student);
66+
}
67+
68+
int total = 0;
69+
int passCount = 0;
70+
size_t highestIndex = 0;
71+
size_t lowestIndex = 0;
72+
73+
for (size_t i = 0; i < students.size(); ++i) {
74+
total += students[i].score;
75+
if (students[i].score >= 60) {
76+
++passCount;
77+
}
78+
if (students[i].score > students[highestIndex].score) {
79+
highestIndex = i;
80+
}
81+
if (students[i].score < students[lowestIndex].score) {
82+
lowestIndex = i;
83+
}
84+
}
85+
86+
const double average = static_cast<double>(total) / students.size();
87+
88+
cout << "\nStudents:\n";
89+
for (const Student& student : students) {
90+
cout << "- " << student.name << ": " << student.score << '\n';
91+
}
92+
93+
cout << "Average: " << average << '\n';
94+
cout << "Highest: " << students[highestIndex].name
95+
<< " (" << students[highestIndex].score << ")\n";
96+
cout << "Lowest: " << students[lowestIndex].name
97+
<< " (" << students[lowestIndex].score << ")\n";
98+
cout << "Passed: " << passCount << "/" << students.size() << '\n';
99+
100+
return 0;
101+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Assessment 02: Core
2+
3+
## Goal
4+
5+
Practice validation, counting, file output, and defensive logic.
6+
7+
## Task
8+
9+
Write a program that reads integer values until `-1`, then:
10+
11+
1. Ignores any value outside range `0..100`.
12+
2. Prints count of valid values.
13+
3. Prints min, max, and average for valid values.
14+
4. Prints a frequency table by tens:
15+
- `0-9`, `10-19`, ..., `90-100`
16+
5. Saves the same report to `core_assessment_report.txt`.
17+
18+
## Quick Run
19+
20+
```bash
21+
g++ -std=c++17 -Wall -Wextra -pedantic main.cpp -o assessment_02_core
22+
./assessment_02_core
23+
```
24+
25+
## Sample Input
26+
27+
```text
28+
12 17 31 77 91 105 64 -3 88 -1
29+
```
30+
31+
## Expected Behavior
32+
33+
- `105` and `-3` are ignored.
34+
- Only values in `0..100` are used for statistics and frequency table.
35+
- If no valid values are entered, print a friendly message and still create the report file.
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#include <fstream>
2+
#include <iostream>
3+
#include <limits>
4+
#include <string>
5+
#include <vector>
6+
7+
using namespace std;
8+
9+
void printAndWriteLine(ostream& out, ofstream& file, const string& line) {
10+
out << line << '\n';
11+
file << line << '\n';
12+
}
13+
14+
int bucketForScore(int score) {
15+
if (score == 100) {
16+
return 9;
17+
}
18+
return score / 10;
19+
}
20+
21+
int main() {
22+
ofstream report("core_assessment_report.txt");
23+
if (!report) {
24+
cout << "Could not create report file.\n";
25+
return 1;
26+
}
27+
28+
vector<int> values;
29+
vector<int> buckets(10, 0);
30+
31+
cout << "Enter integer values (0-100). End with -1.\n";
32+
while (true) {
33+
int value = 0;
34+
if (!(cin >> value)) {
35+
cout << "Invalid input. Stopping read.\n";
36+
break;
37+
}
38+
39+
if (value == -1) {
40+
break;
41+
}
42+
43+
if (value < 0 || value > 100) {
44+
cout << "Ignoring out-of-range value: " << value << '\n';
45+
continue;
46+
}
47+
48+
values.push_back(value);
49+
++buckets[bucketForScore(value)];
50+
}
51+
52+
if (values.empty()) {
53+
printAndWriteLine(cout, report, "No valid values were entered.");
54+
printAndWriteLine(cout, report, "Report saved to core_assessment_report.txt");
55+
return 0;
56+
}
57+
58+
int minValue = values[0];
59+
int maxValue = values[0];
60+
int sum = 0;
61+
for (int value : values) {
62+
sum += value;
63+
if (value < minValue) {
64+
minValue = value;
65+
}
66+
if (value > maxValue) {
67+
maxValue = value;
68+
}
69+
}
70+
71+
const double average = static_cast<double>(sum) / values.size();
72+
73+
printAndWriteLine(cout, report, "Valid count: " + to_string(values.size()));
74+
printAndWriteLine(cout, report, "Minimum: " + to_string(minValue));
75+
printAndWriteLine(cout, report, "Maximum: " + to_string(maxValue));
76+
printAndWriteLine(cout, report, "Average: " + to_string(average));
77+
printAndWriteLine(cout, report, "Frequency table:");
78+
79+
for (int i = 0; i < 10; ++i) {
80+
int start = i * 10;
81+
int end = (i == 9) ? 100 : (start + 9);
82+
string label = to_string(start) + "-" + to_string(end) + ": " + to_string(buckets[i]);
83+
printAndWriteLine(cout, report, label);
84+
}
85+
86+
printAndWriteLine(cout, report, "Report saved to core_assessment_report.txt");
87+
return 0;
88+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# C++ Level Assessments
2+
3+
Use these assessments after finishing each level to check practical readiness.
4+
5+
## Assessment Order
6+
7+
1. [01-foundations](./01-foundations/README.md)
8+
2. [02-core](./02-core/README.md)
9+
10+
Each assessment contains:
11+
12+
- `README.md` with requirements and sample input/output.
13+
- `main.cpp` with a reference implementation you can run and inspect.

0 commit comments

Comments
 (0)