Hi my code compiles fine but when i run it i have to first enter the "mark" and then i need to enter the case. How do i alter the code so i do not need to enter anything for the case?
I know I can use a while
loop or just else if but i want to get this working with switch
case.
import java.util.*;
public class GradeCalcCASE {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int choice;
double m;
//Sets ^^^ m as the mark that the user inputs
System.out.println("Please enter the mark");
m = sc.nextDouble();
choice = sc.nextInt();
if(m<0) {choice = 1;}
else if(m>100) {choice = 2;}
else if(0<=m && m<50) {choice = 3;}
switch(choice) {
case 1:
System.out.println("Invalid mark");
break;
case 2:
System.out.println("Invalid mark");
break;
case 3:
System.out.println("F");
break;
}
}
}