954,483 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

basketball game keeping score

This is what i have for code this far, i need help trying to keep score here. Any help would be well appreciated thanks

int sum = 0, teamScore, numPoints, score1 = 0, score2 = 0;

while (teamScore != -999)
{
cout << "Did team 1 or team 2 score? (Enter 1, 2 or -999 to quit): ";
cin >> teamScore;
cout << "How many points did they score? (1, 2, or 3): ";
cin >> numPoints;

if (teamScore ==1 && teamScore != -999)
{
cout << "Team 1" << score1 = sum + numPoints;
cout << "Team 2" << score2 = sum + numPoints;
}
else if (teamScore ==2 && teamScore != -999)
{
cout << "Team 1" << score1 = sum + numPoints;
cout << "Team 2" << score2 = sum + numPoints;
}
xxxSuperTrooper
Newbie Poster
2 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
 

if (teamScore ==1 && teamScore != -999)

If team = 1 it can't be -999. Simplify both if statements

cout << "Team 1" << score1 = sum + numPoints;
cout << "Team 2" << score2 = sum + numPoints;

Did they both score the points? Once the output is done, what's the value of sum ? Is sum important?

WaltP
Posting Sage w/ dash of thyme
Moderator
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You