ppt
源程序代码:
package text;
import java.util.Scanner;
class Scored{
int scored;
void set(){
Scanner sc=new Scanner(System.in);
try{
System.out.println("请输入0到100间的成绩");
scored=sc.nextInt();
}
catch(Exception e){
System.out.println("输入有误,成绩应该为0-100之间的实数");
set();
}
}
void show(){
if(scored<60&&scored>=0) System.out.println("不及格");
else if(scored>=60&&scored<70) System.out.println("及格");
else if(scored>=70&&scored<80) System.out.println("中");
else if(scored>=80&&scored<90) System.out.println("良");
else if(scored>=90&&scored<100) System.out.println("优");
else {System.out.println("输入范围不正确,请重输");
set();
show();
}
}
}
public class Sh extends Scored{
public static void main(String Args[]){
Scored sco=new Scored();
sco.set();
sco.show();
}
}