Where do I put this IF/ELSE/ or WHILE statement ?

In this exercise, I'm suppose ask the user if the answer is correct if the grade is 100 or higher. With the current situation, you can put in any number and then a negative to add them up.
Thanks for your help in advance.

//Ch7Lab2.cpp
//Calculates the total points earned on projects
//and tests, then assigns a grade, and then displays
//the total points earned and grade

#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main()
{
//declare variables
int score = 0;
int totalPoints = 0; //accumulator
char grade = ' ';

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

while (score >= 0)
{
//add score to accumulator
totalPoints = totalPoints + score;
//get next score
cout << "Next score (negative number to stop): ";
cin >> score;
} //end while

//assign grade
if (totalPoints >= 360)
grade = 'A';
else if (totalPoints >= 320)
grade = 'B';
else if (totalPoints >=280)
grade = 'C';
else if (totalPoints >=240)
grade = 'D';
else grade = 'F';
//end ifs

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

return 0;
} //end of main function
Last edited on
ur prog is fine, but instead of giving the grades on the basis of marks give them on percentage, for that just take a accumuter just b4 the end of while loop, that way everyone will get grades according to their marks......
For the assignment, I need to mod it so that if the user enters 100 or more for score, then the program ask them, "Are you sure?" and if the person say yes, it will record it. But, where do I put that ?
what do you mean by "if the user enters 100 or more for score"? is it every time the user enter 100 and above score?
will it stop when the user enters a point(s) 100 below?
Yes, if the score is less than 100 then it process through normally. But when the score is 100 or more, it will display the message - "Are you sure this is correct?" And then the user type in a choice and it will either record it or not depending on the choice. Then it goes back to normal.

With the current program, I don't know where to put that instruction in there. If anyone can help me, that would be great.
Last edited on
Topic archived. No new replies allowed.