1
Can someone help me fix my points/score system in c++?
Emel1235JR (0)

code:

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
int score = 0;
int number;

cout << "This is a math game." << endl ;
cout << "You will get some tasks, every task is one point." << endl ;
cout << "But if you fail one you lose." << endl ;
cout << " " << endl ;

cout << "0 + 5 = " ;
cin >> number ;

if(number == 5){
cout << "Next" << endl ;
 score = score + number;

score++;
}else{
cout << "Fail" << endl ;
cout << "Your score is: " << score << endl ;
return 0;
}

cout << "5 + 13 = " ;

cin >> number ;

if(number == 18){
cout << "Next" << endl ;
 score = score + number;

score++;
}else{
cout << "Fail" << endl ;
cout << "Your score is: " << score << endl ;
return 0;
}

cout << "18 - 6 = " ;
cin >> number ;

if(number == 12){
cout << "Next" << endl ;
 score = score + number;

score++;
}else{
cout << "Fail" << endl ;
cout << "Your score is: " << score << endl ;
return 0;
}

}

You are viewing a single comment. View All
Answered by mat1 (2242) [earned 5 cycles]
View Answer
2
ryanhcode (84)

Can you tell us what is wrong and give us a link to the repl?