/*编写一个程序,此程序在运行时要求用户输入一个 整数,代表某门课的考试成绩,程序接着给出“不及格”、“及格”、“中”、“良”、“优”的结论。
李国帅 2015.11.11*/
import java.util.Scanner;
class Scored{
int scored;
private Scanner sc;
void get(){
sc = new Scanner(System.in);
try{
System.out.println("请输入0到100间的成绩");
scored=sc.nextInt();
}
catch ( ArithmeticException e){
System.out.println("请输入有误,请重输");
get();
}
catch(Exception e){
System.out.println("请输入有误,请重输");
get();
}
}
void show(){
if(scored<60&&scored>=0)
System.out.println("不及格");
if(scored<70&&scored>=60)
System.out.println("及格");
if(scored<80&&scored>=70)
System.out.println("中");
if(scored<90&&scored>=80)
System.out.println("良");
if(scored<=100&&scored>=90)
System.out.println("优");
if(scored>100||scored<0)
{
System.out.println("输入范围不合适,请重输");
get();
show();
}
}
}
public class Fen extends Scored{
public static void main(String Args[]){
Scored sco=new Scored();
sco.get();
sco.show();
}
}