码迷,mamicode.com
首页 > 其他好文 > 详细

及格问题

时间:2015-11-18 21:32:16      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:

package demo;
import javax.swing.JOptionPane;

class NotNumber extends Exception{
}
public class Credit {
    public static void main(String[] args){
        int cre = 0;
        String c;
        try{
        c=JOptionPane.showInputDialog("请输入成绩:");
        cre = Integer.parseInt(c);
        }
        catch(Exception e){    
            cre = 200;
        }
        if(cre<60)
        {
            JOptionPane.showMessageDialog(null,"不及格", "result",JOptionPane.INFORMATION_MESSAGE);
        }
        else if(cre<70){
            JOptionPane.showMessageDialog(null,"及格", "result",JOptionPane.INFORMATION_MESSAGE);
        }
        else if(cre<80){
            JOptionPane.showMessageDialog(null,"中", "result",JOptionPane.INFORMATION_MESSAGE);
        }
        else if(cre<90){
            JOptionPane.showMessageDialog(null,"良", "result",JOptionPane.INFORMATION_MESSAGE);
        }
        else if(cre<=100){
            JOptionPane.showMessageDialog(null,"优", "result",JOptionPane.INFORMATION_MESSAGE);
        }
        else if(cre==200){
            JOptionPane.showMessageDialog(null,"输入数据有误,请重新输入", "worning",JOptionPane.INFORMATION_MESSAGE);
        }
    }
    
}

及格问题

标签:

原文地址:http://www.cnblogs.com/19950216z/p/4975729.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!