Trying to write a program that calculates a students grade based on how many assignments have been graded. I am using a switch case since there is a total of 5 assignments, however when I enter case 1, and enter in how many I got out of 100, it just closes the program it doesn't go to the next part any ideas?
1.
Change the input to an int and remove the ' ' to make the switch work more smoothly.
2.
The /100 is unnecessary unless the score is not out of 100.
eg. if the score was out of 40 not out of 100 it would be:
(assign1 / 40) * 100
3.
Change grade to char variable. then do this to out put it:
1 2
grade = calculategrade(total);
cout<< "Your grade is: "<< grade <<endl;
4. Add some method of stopping the program to view the result, I wouldn't recommend it for an important program but this should work here if you put it before return 0;
system("PAUSE");
Basically your math was a bit off and you weren't outputting the result properly.
Your problem is that you don't have a loop. Assuming you enter '1' as the input, you enter the grade, calculate a 'total', calculate a grade, drop out of the switch statement and exit the program.
My guess is you want an outer loop like for (int input = 1; input <= 5; input++) ...
This would replace lines 19 and 20.
At the end of the loop you would calculate the total and grade letter.
A loop? Don't think he needs one, the way he's structured it you would put in the number of assignments, say 3, then the scores for those, say 98, 15 and 40, then those would be totaled as a percentage based on max scores and weighting and then converted to a lettered grade.
So each case would include the calculations and inputs from the cases before it plus the calculation and input for the last assign graded.
It's easier with a loop and that's the way I'd do it too, but he said he wanted to use a switch statement.