๐ฎ Project 1: Math Speed Drill
๐ Project Overview
Property | Details |
---|---|
Project Name | Math Speed Drill Game |
Language | C++ |
Difficulty Level | Beginner |
Main Concepts | Loops, Random Numbers, Time Calculation |
Game Type | Timed Challenge |
Target User | Students improving mental math speed |
๐ฏ Objective
To challenge users with simple math problems (addition/subtraction) and measure how quickly they answer 5 of them.
๐ Features
-
5 random math questions.
-
Measures total time taken to answer.
-
Reports time and score at the end.
-
Encourages fast, accurate thinking.
๐ง Tools Required
-
C++ compiler
-
Timer support via
<chrono>
-
IDE (Code::Blocks / VS Code) or terminal
๐ป Source Code
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <chrono>
using namespace std;
using namespace std::chrono;
int main() {
srand(time(0));
int correct = 0;
cout << "๐ง Welcome to Math Speed Drill!\n";
cout << "You will be given 5 simple addition or subtraction problems.\n";
cout << "Try to answer them as fast and correctly as you can!\n\n";
auto start = high_resolution_clock::now(); // Start timer
for (int i = 1; i <= 5; ++i) {
int a = rand() % 50 + 1;
int b = rand() % 50 + 1;
int operation = rand() % 2; // 0 for +, 1 for -
int answer, user;
if (operation == 0) {
answer = a + b;
cout << "Q" << i << ": " << a << " + " << b << " = ";
} else {
answer = a - b;
cout << "Q" << i << ": " << a << " - " << b << " = ";
}
cin >> user;
if (user == answer) {
cout << "✅ Correct!\n";
correct++;
} else {
cout << "❌ Wrong. Correct answer is: " << answer << "\n";
}
}
auto stop = high_resolution_clock::now(); // Stop timer
auto duration = duration_cast<seconds>(stop - start);
cout << "\n⏱️ Total Time: " << duration.count() << " seconds\n";
cout << "๐ Final Score: " << correct << "/5\n";
return 0;
}
๐ง Learning Concepts
-
chrono
for measuring time. -
Use of randomization and conditionals.
-
Beginner-level problem-solving practice.
๐ฏ Sample Output
๐ง Welcome to Math Speed Drill!
Q1: 14 + 27 = 41
✅ Correct!
Q2: 35 - 19 = 16
✅ Correct!
...
⏱️ Total Time: 21 seconds
๐ Final Score: 4/5
๐ฎ Project 2: Even-Odd Identifier Challenge
๐ Project Overview
Property | Details |
---|---|
Project Name | Even-Odd Identifier Game |
Language | C++ |
Difficulty Level | Beginner |
Main Concepts | Loops, Modulo Operator, Scorekeeping |
Game Type | Classification (Math logic) |
Target User | Kids learning even and odd numbers |
๐ฏ Objective
This game tests how quickly and accurately a user can identify whether a number is even or odd. Great for early learners or warm-up logic drills.
๐ Features
-
10 random numbers shown.
-
User must type "even" or "odd".
-
Game checks answers and gives final score.
-
Simple, intuitive logic-building.
๐ป Source Code
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <string>
#include <algorithm>
using namespace std;
int main() {
srand(time(0));
int score = 0;
cout << "๐ข Welcome to the Even-Odd Identifier Game!\n";
cout << "You will be shown 10 random numbers.\n";
cout << "Type 'even' or 'odd' based on the number shown.\n\n";
for (int i = 1; i <= 10; ++i) {
int number = rand() % 100 + 1;
string answer;
cout << "Q" << i << ": " << number << " is (even/odd)? ";
cin >> answer;
// Convert input to lowercase
transform(answer.begin(), answer.end(), answer.begin(), ::tolower);
bool isEven = number % 2 == 0;
if ((isEven && answer == "even") || (!isEven && answer == "odd")) {
cout << "✅ Correct!\n";
score++;
} else {
cout << "❌ Wrong. It is actually " << (isEven ? "even" : "odd") << ".\n";
}
}
cout << "\n๐ Game Over. You got " << score << " out of 10 correct.\n";
return 0;
}
๐ง Learning Concepts
-
Using
modulo (%)
to check even/odd. -
string
manipulation (transform
to lowercase). -
Simple conditional logic.
✅ Sample Output
Q1: 33 is (even/odd)? odd
✅ Correct!
Q2: 70 is (even/odd)? odd
❌ Wrong. It is actually even.
...
๐ Game Over. You got 8 out of 10 correct.
๐ง Takeaways for Beginners
-
Practice with simple logic-based conditions.
-
Intro to
string
,transform
, and modulo. -
Builds fast decision-making for math skills.
๐ฆ Compilation Instructions
To compile and run either game:
g++ speed_drill.cpp -o speed
./speed
g++ even_odd_game.cpp -o evenodd
./evenodd