I don't understand the problem. assuming that grade is a char, the error message will print if the grade is not set to one of A, B, C, D, F, or X. Please clarify the question or show a complete program that demonstrates the problem.
I still don't know what the question is. However I suggest that you move the test of invalid characters into the default case of the switch so that the user knows when they have entered a bad grade. initialize grade to something like 'Z' so that you enter the while loop immediately. You don't need to duplicate the cin before the loop. there only needs to be one at the top and inside of the while loop. I have no idea if I am answering your question but I do think that your code needs to be structurally changed.
you are right i don't have it fully structured correct ~ this is the prompt im working off of.
Flowchart and implement a program that obtains letter grades as input from a user, then coverts each letter grade into grade points. The program should total all the grade points and output the total grade points and the grade point average (note: you may have to track the total number of inputs to calculate the grade point average). The program should validate all user inputs (using do-while loops). Use a while loop for the main structure of the program that will stop accepting letter grades when the user inputs X.
im trying to make the if statement and Boolean variable so i can make the whole thing a while loop then have the error checking part a small do while that will exit that part when input is vaild then enter the switch statement. if i could use the switch statement to error check but i cant (professor doesn't want it.) talking to her she also says theres a do while loop at the bottom but what that one will do i dont know,
they also give me this tip,
The easiest way to approach this problem is to first implement the while loop. You will need to accept input to initialize the LCV prior to entering the while loop and then again accept input at the end of the while loop to update the LCV. Once you have completed the while loop and it running properly implement the do-while loops (in place of the inputs) to validate the input. Note, you will need to do this twice once where you initialize the LCV and again where you change the LCV. DO NOT JUST CHECK FOR G your program should be able to handle any character that is not valid.