Hey guys..
I'm having a little issue figuring out how to get my program to restart if a wrong parameter is entered.
Can anyone point me in the right direction?
// Write a program that allows the user to enter the grade scored in a programming class (0-100).
// If the user scored a 100 then notify the user that they got a perfect score.
#include <iostream>
usingnamespace std;
void getScore(int);
int main()
{
cout << "Enter testscore: ";
int testScore;
cin >> testScore;
if(testScore <= 100 && testScore >= 0)
{
getScore(testScore);
} else
{
cout << "Sorry dude, you entered a wrong score, try again: ";
// What to enter in order to start over??
}
}
void getScore(int x) // Function to print out the students testscore.
{
if(x >= 90 && x <= 100) cout << "\n\n\n\tYou got an A. \n\n\n\tCONGRATZ!\n\n\n" << endl;
if(x >= 80 && x <= 89) cout << "\n\nYou scored a B!\n\n" << endl;
if(x >= 70 && x <= 79) cout << "\n\nYou scored a C!\n\n" << endl;
if(x >= 60 && x <= 69) cout << "\n\nYou scored a D!\n\n" << endl;
if(x >= 0 && x <= 59) cout << "\n\nYou scored a F\n\n" << endl;
}