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有人能告诉我为什么这行不通吗?我甚至不知道该从哪里开始修理它。上面写着我的其他行没有if,但是if就在上面.
发布于 2014-12-11 00:46:34
去掉所有;后的if ()或更好的意义条件语句
例如:
if(GPA < 2.5); {
System.out.println("You are failing.");
}更改为
if(GPA < 2.5) {
System.out.println("You are failing.");
}对其他if语句也执行相同的处理。
发布于 2014-12-11 00:46:38
删除if(GPA >= 3.5); {和类似if语句中的分号。
发布于 2014-12-11 00:50:25
删除条件语句后的;。
https://stackoverflow.com/questions/27413525
复制相似问题