Код: Выделить всё
import java.util.Scanner;
public class LabL2 {
public static void main(String[] args) {
double score; // Error occurs here
Scanner input = new Scanner(System.in); // Scanner declared here
System.out.print("Enter score: ");
score = input.nextInt();
if(score < 0 || score > 100)
{
System.out.println( "Invalid test score");
}
else
{
switch(score/10)
{
case 10:
case 9:
System.out.println("The grade is A");
break;
case 8:
System.out.println("The grade is B");
break;
case 7:
System.out.println("The grade is C");
break;
case 6:
System.out.println("The grade is D");
break;
default:
System.out.println("The grade is F");
break;
}
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/792 ... the-switch
Мобильная версия