Last week for class I wrote the program below. This week part of our assignments are to the program take this program and modify it so the user can display the grade for as many students as they choose.
What I am not understanding is, is it asking to be able to let the user enter each students name individually and then have it display a list of names with the grades associated with it? If this is the case would this be accomplished with a string statement? if it is a string statement I am not sure I would know to do it.
Or is it just asking to display a whole bunch of grades at the end for each student the user enters? If this is the case would I go about this by writing a variable that would keep track of each score seperatly until the user says every score and student is entered?
Sorry I feel super lost this week in C++
#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 for each student
cout << endl;
cout << "Total points: " << totalPoints << endl;
cout << "Grade: " << grade << endl;
return 0;
}//end of main function
Thanks for the help everyone!!