有人可以幫助我解決我的代碼,使其工作。在控制檯中,它不允許輸入任何內容。有人可以在他們的計算機上測試代碼並向固定代碼發送評論嗎?如果不是,你可以告訴我與我的代碼問題?爲什麼我的輸入掃描儀和我的程序的其餘部分不工作?
String yes =「yes」;
System.out.println("Do you have gym this semester?");
input.nextLine();
if (input.equals(yes)){
int Gym;
double GymGpa = 0;
System.out.println("Gym = ");
Gym= input.nextInt();
input.close();
if (Gym >100){
System.out.println("You have mistyped something");
}
if (Gym >= 94 && Gym < 101){
System.out.println("You have an A");
GymGpa = 4.0;
System.out.println(GymGpa);
}
if (Gym < 94 && Gym >=90){
System.out.println("You have an A-");
GymGpa = 3.7;
System.out.println(GymGpa);
}
if (Gym < 90 && Gym >=87){
System.out.println("You have a B+");
GymGpa = 3.3;
System.out.println(GymGpa);
}
if (Gym < 87 && Gym >=80){
System.out.println("You have a B");
GymGpa = 3.0;
System.out.println(GymGpa);
}
if (Gym < 80 && Gym >=77){
System.out.println("You have a B-");
GymGpa = 2.7;
System.out.println(GymGpa);
}
if (Gym < 77 && Gym >=73){
System.out.println("You have a C+");
GymGpa = 2.3;
System.out.println(GymGpa);
}
if (Gym < 73 && Gym >=70){
System.out.println("You have a C");
GymGpa = 2.0;
System.out.println(GymGpa);
}
if (Gym < 70 && Gym >=67){
System.out.println("You have a C-");
GymGpa = 1.7;
System.out.println(GymGpa);
}
if (Gym < 67 && Gym >=67){
System.out.println("You have a D+");
GymGpa = 1.3;
System.out.println(GymGpa);
}
if (Gym < 67 && Gym >=63){
System.out.println("You have a D");
GymGpa = 1.0;
System.out.println(GymGpa);
}
if (Gym < 63 && Gym >=60){
System.out.println("You have a D-");
GymGpa = 0.7;
System.out.println(GymGpa);
}
if (Gym < 60){
System.out.println("You have a F");
GymGpa = 0.0;
System.out.println(GymGpa);
}//End of Gym
}else if (input.equals("no")){
}
感謝你回答,但不起作用。 –