Hey, I've been working on this very simple math quiz over the last 2 days (only been learning c++ for 3 days now) and wanted to see if I could make it better. I was wondering if there was a way to add a scoreboard to my quiz like every time u get a question correct u add 1 point to the scoreboard. Here is my code:
#include <iostream>
usingnamespace std;
int main ()
{
cout << "Welcome to Aidan's math quiz 1.0 \n";
cout << "This will be an easy 10 question math quiz \n";
cout << "Remember: (spelling does count!) \n";
cout << "Type play when you want to being :) \n";
string operation;
string answer;
cin >> operation;
if (operation == "play"){
cout << "Let's begin! \n";
}else{
cout << "We can't start unless you press play! Press any key and start over. \n";
return 0;
}
cout << "Question 1: \n";
cout << "10 - 17 + 16 + (12*12)"<<endl;
cin >>answer;
if (answer == "153")
{
cout << "Correct! \n";
}else{
cout << "Incorrect. Try again on Question 2! \n \n";
}
cout << "Question 2 \n";
cout << "What is the six letter acronym for the order of operation? (Use all capital letters) \n";
cin >> answer;
if (answer == "PEMDAS"){
cout << "Correct! \n";
}else{
cout << "Incorrect. Try again on Question 3! \n \n";
}
cout << "Question 3 \n";
cout << "What is 100/5? \n";
cin >> answer;
if (answer == "20"){
cout << "Correct! \n";
}else{
cout << "Incorrect. Try again on Question 4! \n \n";
}
cout << "Question 4 \n";
cout << "What is the theorem that says a squared + b squared = c squared? (Make sure to capitalize each word.) \n";
cin >> ws;
getline(cin, answer);
if (answer == "Pythagorean Theorem"){
cout << "Correct! \n";
}else{
cout << "Incorrect! Try again on Question 5! \n \n";
}
cout << "Question 5 \n";
cout << "97+96+95+94" << endl;
cin >> answer;
if (answer == "382"){
cout << "Correct! \n";
}else{
cout << "Incorrect. Try again on Question 6! \n \n";
}
cout << "Question 6 \n";
cout << "Mary has killed 25 people today. \nMary then hides 17 of the bodies before the cops find her hiding them. \nHow many were found unburied? \n";
cin >> answer;
if (answer == "8"){
cout << "Correct! \n";
}else{
cout << "Incorrect. Try again on Question 7! \n \n";
}
cout << "Question 7 \n";
cout << "Mary is now in prison with 523 other people. \nMary then escapes along with 187 other people. \nHow many people are left in the prison? \n";
cin >> answer;
if (answer == "336"){
cout << "Correct! \n";
}else{
cout << "Incorrect. Try again on Question 8! \n \n";
}
cout << "Question 8 \n";
cout << "After hearing about the escape of 187 prison mates, \n825 police officers were called onto the case to find all of them. \nUnfortunately, the 187 escaped prison mates killed 239 of them \n";
cout << "Then 114 more officers were called on. \nHow many police officers are still searching? \n";
cin >> answer;
if (answer == "700"){
cout << "Correct! \n";
}else{
cout << "Incorrect. Try again on Question 9! \n \n";
}
cout << "Question 9 \n";
cout << "The 700 remaining police now decide to only go after Mary who started this all. \nMary kills in groups of 2 all the time and managed to kill 58 groups of 2 police \n";
cout << "officers before the police finally kill her. \nHow many of the remaining police officers are still alive? \n";
cin >> answer;
if (answer == "584"){
cout << "Correct! \n";
}else{
cout << "Incorrect. Try again on the Final Question \n \n";
}
cout << "Final Question! Question 10 \n";
cout << "What's 9 + 10? \n";
cin >> answer;
if (answer == "19"){
cout << "You not stupid! \n";
cout << "Congratulations! \n";
}elseif(answer == "21"){
cout << "You stupid! \n";
}else{
cout << "Incorrect! You failed the final Question! \n \n";
}
cout << "Thank you for taking Aidan's Math Quiz 1.0! \nSee you at Aidan's Math Quiz 2.0! \n";
return 0;
}
also thx to gentlegal and gentleguy for helping me with this