+ 1
How to create program of grade using switch method
7 Respuestas
+ 2
i want to create program of students getting A,B,C,D grade depended on there percentage using switch method
+ 2
As code is language specific and here th language is not specified I will share the logic alone.
// let the percent be stored in variable percent.
// convert percent into integer and divide by 10 (ignore the reminder). let this value be stored in variable V.
// now the switch statement
switch(V) {
case 10:
case 9: GRADE = 'A';
break;
case 8: GRADE = 'B';
break;
case 7: GRADE = 'C';
break;
// repeat this as much as youwish😉
}
+ 1
What do you exactly want to do
+ 1
I don't think Switch is a good idea here. You cannot use Switch with > or <. Use if statements instead
+ 1
but i want to create with switch
+ 1
Switch with ranges doesn't work in Java, so you'll need to use if else.
+ 1
the best way to do it is using if ....statment .but if you have to use switch. you will have to use an integer variable to check the grades ....
hope it helps...