Help with Study Guide Question---NOT HOMEWORK

This is a question on my study guide. I am not understanding switches very well.

The questions says a professor determines his grades based on the following table.

score
90-100

80-89

70-79

60-69

<60

grade
A

B

C

D

F

Assign the appropriate value to the variable grade(character) based on the variable score(integer). Use the switch structure.

We were told you are not supposed to use relational operators in JAVA in a switch (char or int).

My thoughts would have been

{
case 1: Grade = "A";
break;
case 2: Grade = "B";
break;
case 3: Grade = "C";
break;
case 4: Grade = "D";
break;
default:
Grade = "F";
}

I just don't know how to work in the grade scale. Any help appreciated.

Comments

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion