I am having the hardest time. I cant use anything advanced it has to be simple loops, while loops and must use switch instead of if statements.
Write a main function to do the following "entering grade" task:
* Ask the user to enter either "E" for entering a number, or "Q" for quit.
* If "E" is entered, the user is asked to enter an integer (grade) ranging from 0 to 100. Your code will print out a letter-grade on screen based on the number entered. If the number is between 0-59, print "F", 61-69 for "D", 70-79 for "C", 80-89 for "B", and 90-100 for "A". Requirement: you MUST use switch rather than if-else statements to implement the task.
* The process will be repeated until a "Q" is entered.
I think you have used switch for wrong thing. Use switch to determine if user entered 'E' or 'Q'. If 'E' calculate grade letter, If 'Q' just exit. Maybe this will help you
1 2 3 4 5 6 7 8 9 10 11 12 13 14
int main()
{
//while( 1 )
// get user choice
//switch choice
//case 'E'
//calculate letter
//case 'Q'
//exit
}
To get grade letter you could switch value grade / 10.
0 - 5 = 'F'
6 = 'D'
7 = 'C'
8 = 'B'
9 - 10 = 'A'
I encourage you to move calculating letter to another function :)
right above my reply has great result(with tiny conceptual problem), just use same platform and change if to switch. case 1, 2 and so on. you will get 90+