I am writing a simple GPA Calculator program for my C++ class. We just learned if else statements this week, so that is what the program does a lot of. If the user does not enter either an A, B, C, D, or F I want it so the program just stops there. How would I do that? I just need something that terminates the program as soon as that user error occurs. If you need any of my source code please let me know.
returnwill exit a function. In this case, it will exit the main(). Yes, you can have multiple returnstatements. When the first one is reached, the function exists. When the main() function exits, the program ends.
Since you are limited to if else statements I would do the following:
write a cout statement asking for user to type a, b, c, d, or f
if (getInput == 'a')
else if (getInput == 'b')
else if(getInput == 'c')
else if(getInput == 'd')
else if(getInput == 'f')