Help with switch and if statements for assignment

For one assignment we had to "Read in a users score (valid input is 0 - 100)
output a letter grade using the standard grading scale". I did that just fine. Then we had to take the grade program with letter grades as input and convert it to a switch. I did that but now for this third assignment I'm stuck.

"Using a switch statement, accept a letter grade from a student. Based on that letter grade, ask a student for their numerical grade. Test to make sure the numerical grade is in the range of the letter grade - if it is, then tell them how many points they are away from the next higher grade, otherwise give them an error."

How do i go about doing this?
suggestion:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
enum Grades{A=65,B,C,D,E,F}; // note the E you won't use but it makes the enum work
enum lowGrades{a=97,b,c,d,e,f}; // similar to the above
/* Receive user's inputs both Letter and grade*/

numLetter=(int)Letter; // this should convert the char type 'letter' to an integer
switch (numLetter) {
            case 65:
            case 97: { if(grade>90&&grade<=100){ /* evaluation of next highest grade*/}
                          else{ cout<<"The grade is not in range..."} ; break; } 
/* Repeat similar cases for b-f [skip E] */

// alternatively you could use cases as follows for the A type grades.
case A:
case a: { /* copy and paste the same operations */

// This would allow for the use of the letters in the actual switch cases because the enum 
// assigns an actual number to them. 

Does this satisfy your requirements?
--Edit--
The numbers assigned to the A and a in their respective enumeration groups come from the standard ascii table.
Last edited on
Ok i got it thank you.
Glad to help :) Good luck!
Topic archived. No new replies allowed.