/********************************************
This program should take users name
and grade and output their name, grade
and letter grade. Then it should repeat
this until "q" is entered. Then tells how
many students their are and how many students
got a certain grade.
********************************************/
#include <iostream>
#include <string>
usingnamespace std;
char getScore()
{
char studentScore = 0;
int score1;
if (studentScore <= 100)
{
score1 = 'A';
}
elseif (studentScore <= 89)
{
score1 = 'B';
}
elseif (studentScore <= 79)
{
score1 = 'C';
}
elseif (studentScore <= 69)
{
score1 = 'D';
}
elseif (studentScore <= 59)
{
score1 = 'F';
}
elseif (studentScore < 0)
{
cout << "Please enter a number between 0 and 100" << endl;
}
else
{
cout << "Invalid entry";
}
return score1;
}
int main()
{
string student;
char score;
int studentScore;
int score1;
bool q = true; // if user enters q, q is is true
cout << "Enter q to see stats of grades" << endl;
cin >> q;
cout << "Enter your name: ";
cin >> student;
cout << "Enter your score: ";
cin >> studentScore;
score = getScore(); // Go to function getScore
while (!q)
{
cout << "Student " << student << " has a grade of " << studentScore <<
" and letter grade: " << score;
}
return 0;
}