本帖最后由 fanlelong 于 2016-4-3 18:28 编辑
import java.util.Scanner;
class Text1Cheng {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);//创建一个键盘录入对象
System.out.print("请输入一个1到100的整数:");
int x = sc.nextInt();//将键盘录入的对象赋于x
while (true) {
if (x>=90&&x<=100) {
System.out.println("优");
break;
}else if (x>=80&&x<=89) {
System.out.println("良");
break;
}else if (x>=70&&x<=79) {
System.out.println("中");
break;
}else if (x>=60&&x<=69) {
System.out.println("及");
break;
}else if (x>=0&&x<=59) {
System.out.println("差");
break;
}else {
System.out.print("输入错误,请重新输入:");
x = sc.nextInt();
}
}
}
}
写的不知道对不对,老师讲的练习题目,自己改了下
|
|