Alright this is homework so I'll keep the code to a minimum.
I think there's a few options here, and it all depends on what you're allowed to use.
1) The easiest option I would think is to "convert" the double to a String, and use a switch statement with the first character of the String. So if it starts with a 9, it's going to be an A, since you aren't calculating A+/A- it seems.
2) You could round down to the nearest tens place, and cast the double to an int
, and use the switch statement with an int
. That way you only have 4 numbers to check. The default
will be your friend here.
manpreet
Best Answer
2 years ago
My instructor wants me to use a switch statement, but I'm calculating the grade of a student and by nature I would think to use double but I can't. The program should ask for user input then by which ever number (example: 92.99) the student enters, print out a letter grade according to the syllabus. Please help! In addition that doesn't work correctly anymore. It doesn't print out the letter grade. This is what I have so far: