编辑代码

public class DemoIf{
	public static void main(String[] args){
		java.util.Scanner s = new java.util.Scanner(System.in);
		System.out.print("请输入成绩:");
		double jgf = s.nextDouble();
		
		if(jgf < 0 || jgf > 100){
			System.out.println("输入数据错误,请重新输入!");
			return;
		}
		int grade = (int)(jgf / 10 );
		String cj = "不及格!";
		switch(grade){//switch语句除以10,然后再判断case的数值。
		case 9: case 10:
			cj = "优秀";
			break;
		case 8:
			cj = "良";
			break;
		case 7:
			cj = "中";
			break;
		case 6:
			cj = "及格";
			break;
		}
		System.out.println("该学生考试成绩" + cj);
		
	}
}