I have a programming project that I have to work on and the way that my instructor is describing me to make this is completely screwed up every time I try it. Here's what it is:
Write a program to accept four quiz scores and a name from a student and calculate the minimum, maximum, sum, and average of the four quiz scores. This program should use one of each type of loop as follows:
A do-while loop should present a menu to the user with the following options:
A – Enter scores for another student
Q – Quit the program
If the user has entered a ‘Q’, then the program will end.
If the user has entered an ‘A’, to enter scores, then the program will prompt for the student’s name. A for loop should be used to prompt the user for exactly 4 quiz scores, one on each execution of the loop. (Inside this for loop should be validation of the user input and re-prompting, if necessary using a while loop to get valid scores which are between 0 and 10 inclusive. After the score is validated, then it should be added to the sum, check to determine if it is less than the previous score (minimum), and checked to determine if it is greater than the previous score (maximum). After the for loop has completed its four rounds, then the average score should be calculated. The output of the minimum, maximum, and average score should then be rounded to two decimal places and output to the screen.
But every time I try to do a do-while loop and input all the information, it doesn't stop looping and I can't get the program to execute the way I want it to. So, can someone please try to either walk me through this or tell me an easier way that I can get this to work???
If you can post the code you have for the do-while loop that's causing an infinite loop, someone here can help figure out what might be going wrong.
Could be that the condition you're checking is always going to be true (or false). If you're checking equality between two values, make sure you're using the equality operator == and not the assignment operator =.