java 错误:
发布网友
发布时间:2024-10-23 22:51
我来回答
共2个回答
热心网友
时间:2024-10-24 14:54
就是你的括号用错而已……你用了中文输入的(),只要改为英文输入的()就可以了。
改正后的代码如下:
import javax.swing.JOptionPane;
public class GradeLevel {
public static void main(String[] args){
String level;
int grade;
boolean gradeBe0_59;
boolean gradeBe60_70;
boolean gradeBe70_80;
boolean gradeBe80_90;
boolean gradeBe90_100;
String number =JOptionPane.showInputDialog("输入成绩:");
grade =Integer.parseInt(number);
gradeBe0_59 =(grade>=0)&&(grade<60);
gradeBe60_70=(grade>=60)&&(grade<70);
gradeBe70_80=(grade>=700)&&(grade<80);
gradeBe80_90=(grade>=800)&&(grade<90);
gradeBe90_100=(grade>=90)&&(grade<100);
level=(gradeBe0_59)?("不及格"):"";
level=(gradeBe60_70)?("及格"):level;
level=(gradeBe70_80)?("中"):level;
level=(gradeBe80_90)?("良"):level;
level=(gradeBe90_100)?("优"):level;
JOptionPane.showMessageDialog(null,level, "成绩等级为" ,JOptionPane.INFORMATION_MESSAGE);
}
}
热心网友
时间:2024-10-24 14:55
有点难