Having trouble with while()

I'm having trouble with this problem in my text book and I've tried a lot of different things but it seems that I don't know what I'm doing. We are using for and while statements so I assume it wants me to use those.
Here is the entire question: Create a program that a teacher can use to enter the midterm and final test scores for any number of students. Each test is worth 200 points. The program should display each student’s grade, which is based on the total points the student earned, as indicated in Figure 7-50. If necessary, create a new project named Introductory19 Project, and save it in the Cpp8\Chap07 folder. Enter the C++ instructions into a source file named Introductory19.cpp. Also enter appropriate comments and any additional instructions required by the compiler. Save, run, and test the program.
It gives me: Total point: (360 – 400)=A , (320 – 359)=B , (280 – 319)=C , (240 – 279)=D , (below 240)=F
Last edited on
As far as the while loop goes for unlimited students this is a possible solution:

int grade, quit = 0,sum = 0, count = 0;
int sentinel = -1;
cout << "Enter Grades or -1 to quit." << endl;
while(quit != sentinel)
{
count = 0;
sum = 0;
while(count < 2)
{
cout << "Enter grade: ";
cin >> grade;
while(grade > 200)
{
cout << "Invalid grade. Enter again: ";
cin >> grade;
}
sum+=grade;
count++;
}
if(sum >= 360 && sum <= 400)
cout << "Grade = A" << endl;
else if(sum >= 320 && sum <= 359)
cout << "Grade = B" << endl;
else if(sum >= 280 && sum <= 319)
cout << "Grade = C" << endl;
else if(sum >= 240 && sum <= 279)
cout << "Grade = D" << endl;
else
cout << "Grade = F" << endl;
cout << "Enter -1 to quit or any other key to continue: ";
cin >> quit;
}
Topic archived. No new replies allowed.