+ 1

How to create program of grade using switch method

24th Aug 2018, 3:54 PM
Shivansh
Shivansh - avatar
7 Respuestas
+ 2
i want to create program of students getting A,B,C,D grade depended on there percentage using switch method
25th Aug 2018, 9:10 AM
Shivansh
Shivansh - avatar
+ 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😉 }
25th Aug 2018, 1:31 PM
Murali Krishnan A
+ 1
What do you exactly want to do
24th Aug 2018, 5:17 PM
Jonas Schröter
Jonas Schröter - avatar
+ 1
I don't think Switch is a good idea here. You cannot use Switch with > or <. Use if statements instead
25th Aug 2018, 9:12 AM
Jonas Schröter
Jonas Schröter - avatar
+ 1
but i want to create with switch
25th Aug 2018, 9:45 AM
Shivansh
Shivansh - avatar
+ 1
Switch with ranges doesn't work in Java, so you'll need to use if else.
25th Aug 2018, 7:52 PM
BlazingMagpie
BlazingMagpie - avatar
+ 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...
26th Aug 2018, 6:59 AM
xegai
xegai - avatar