课后题
package youliang;
import javax.swing.*;
public class DengJi {
public static void main(String args[]){
String s=new String();
int fen,n=0;
while(n==0)
{
try{
s=JOptionPane.showInputDialog("请输入分数:");
fen=Integer.parseInt(s);
if(fen>0&&fen<60)
{JOptionPane.showMessageDialog(null, "不及格!");n=1;}
if(fen>60&&fen<=70)
{JOptionPane.showMessageDialog(null, "及格!");n=1;}
if(fen>70&&fen<80)
{JOptionPane.showMessageDialog(null, "中!");n=1;}
if(fen>80&&fen<90)
{JOptionPane.showMessageDialog(null, "良!");n=1;}
if(fen>90&&fen<=100)
{JOptionPane.showMessageDialog(null, "优!");n=1;}
if(fen<0||fen>100)
{JOptionPane.showMessageDialog(null, "请按要求输入分数!");}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, "输入错误,请重新输入:");
}
finally
{
System.out.println("执行finally!");
}
}
}
}