import java.lang.NumberFormatException;
import javax.swing.JOptionPane;
public class StudentGrade {
private static String b = null;
public static void main(String[] args){
StudentGrade sd=new StudentGrade();
System.out.println("你的考试级别为:"+sd.AboutLever());
}
public String AboutLever() throws NumberFormatException
{
String Lever = null;
try{
b=JOptionPane.showInputDialog("请输入您的成绩:");
int a=(Integer.valueOf(b)).intValue();
if(a>100 || a<0){
JOptionPane.showMessageDialog(null,"输入成绩错误! 程序退出!");
System.exit(0);
}
else{
a=a/10;
}
switch (a){
case 10:
case 9:
Lever="优秀";
break;
case 8:
Lever="良好";
break;
case 7:
Lever="中等";
break;
case 6:
Lever="及格";
break;
default:
Lever="不及格";
}
}catch(NumberFormatException ne){
JOptionPane.showMessageDialog(null,"请您输入数字!");
System.exit(0);
}
return Lever;
}
}