When the score is greater than 100 points the program should ask me whether the score is correct The program should ask me whether the score is correct. The program should not add a score that is more than 100 points to the accumulator with out permission (if(score > 1000 cout << "is the score correct?: ";)cin >> permission;.)Modify the program appropiatelly. **If you dont understand my instructions. Please help me correct this program. Please explain to me the errors I made.

//Lab7-2.cpp - displays the total points earned and grade
 //Created/revised by <your name> on <current date>

 #include <iostream>

 using namespace std;

 int main()
 //declare variables
 int score = 0;
 int totalPoints = 0; //accumulator

 char permission = ' ';

 //get first score
 cout << "First score (-1 to stop): ";
 cin >> score;

while(score < 100)                                               

if(score > 100)                                                 
out << "is the score correct?: ";
cin >> permission;
if(toupper(permission == Y)
totalPoints+= score; // Accumulator
cout << "NextScore:  ";
cin >> score; 
cout << "Next Score (100 to stop): ";
cin >> score;


 //display the total points and grade
cout << "Total points earned: " << totalPoints << endl;

 return 0;
 } //end of main function

Edited by Nick Evan: Added CODE-tags.

4 Years
Discussion Span
Last Post by Zaqmjua

you need to fix the opening and closing brackets for your conditionals like the if conditions and while loop to tell which statements are included in each


include <iostream>

using namespace std;

int main()
    int points,totalpoints=0;
    char permit;
    while (points!=-1)
        cout << "Input points. Type -1 to stop. ";
        cin >> points;
        cout << endl;
        if (points<100 && points>0)
        else if (points>100)
            cout << "The number is over 100. Add to accumulator ?";
            cin >> permit;
            cout <<endl;
            if (permit=='Y' || permit=='y')
    cout << "Total points:" << totalpoints;

You have a mistake in the 23rd line where it is supposed to be cout instead of out.
Another error is in the 26 line where it should be 'Y'
I don't know how should system ("pause") work so i would just delete it from the code (I guess you are coding in DevC++)
And yeah, as the guy above me said, you should open paranthesis everytime you want something more that oone line done in a loop such as while or for, and in an if statement.
This is my code for this exercise. I wasn't exactly sure is it supposed to say "input points. Type -1 to stop." everytime so iI just left it that way. Hope this helps !

Edited by Zaqmjua

Votes + Comments
We don't do homework for people - he *help* them find their own solutions
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.