标签:
程序代码:
import java.util.*;
class Pan
{
double num;
void setNum()
{
Scanner shu=new Scanner (System.in);
try
{
num=shu.nextDouble();
if(num>100||num<0)
throw new Exception();
}
catch(Exception a)
{
System.out.println("输入有误,请重新输入!");
setNum();
}
}
void showNum()
{
if(num>0&&num<60) System.out.println("不及格");
if(num>60&&num<=70) System.out.println("及格");
if(num>70&&num<=80) System.out.println("中");
if(num>80&&num<=90) System.out.println("良");
if(num>90&&num<=100) System.out.println("优");
}
}
public class PanDuan {
public static void main(String[] args) {
// TODO 自动生成的方法存根
System.out.print("请输入分数:");
Pan qq=new Pan();
qq.setNum();
qq.showNum();
}
}
程序截图:
结果截图:
标签:
原文地址:http://www.cnblogs.com/mengqimoli/p/4965167.html