实验内容
1、练习分支结构 (GradeIdentify.java)
定义一个学生的JAVA成绩为n(0到100的整数),编写一个程序输出这个学生成绩的等级,比如76为“中”。(优:>=90;良:>=80;中:>=70;及格:>=60;不及格:<60)
第1题
package ex02;
import java.util.Scanner;
public class GradeIdentify {
public static void main (String[] args) {
GradeIdentify score = new GradeIdentify();
score.getGrade();
}
void getGrade() {
System.out.print("请输入您的Java成绩:");
Scanner input = new Scanner(System.in);
int your_score = input.nextInt();
if (your_score>=90 && your_score<=100) {
System.out.println("您的成绩为:优!\n");
}
else if (your_score>=80 && your_score<=89) {
System.out.println("您的成绩为:良!\n");
}
else if (your_score>=70 && your_score<=79) {
System.out.println("您的成绩为:中!\n");
}
else if (your_score>=60 && your_score<=69) {
System.out.println("您的成绩为:及格!\n");
}
else {