package gpatogradecalculator;
import java.util.Scanner;
public class GPAtoGradeCalculator {
public static void main(String[] args) {
// TODO code application logic here
double GPA = 0.0;
Scanner response = new Scanner(System.in);
System.out.println("Please enter your GPA: ");
GPA = response.nextDouble();
if(GPA >= 3.5); {
System.out.println("Your GPA is an A.");
} else if(3.0<=GPA && GPA<3.5); {
System.out.println("Your GPA is a B.");
} else if(2.5<=GPA && GPA <3.0); {
System.out.println("Your GPA is a C.");
}
if(GPA < 2.5); {
System.out.println("You are failing.");
}
} // end main
} // end class
有谁能告诉我为什么这不起作用吗?我甚至不知道从哪里开始修复它。它说,我的别的行是没有如果,但如果是对他们之上......GPA编号为GPA信件计划。不知道为什么它不起作用
希望你意识到你可以简化最后3条if语句来测试第一个条件。由于这些是其他子句,因此您已经检查过它是否更高。 – RobP 2014-12-11 00:49:06
'if()'后面不需要分号。最后一个if(> 2.5)应该是'else if'。此外,标题是坏的,它应该是错误的名称,这与GPA无关:) – 2014-12-11 00:49:20