CoreJava/exp4/Undergraduate.java
2024-05-09 09:10:51 +08:00

33 lines
803 B
Java

package exp4;
class Undergraduate extends Student {
public Undergraduate(String name)
{
super(name,"本科生");
}
public void calculateGrade() {
int total = 0;
double average = 0;
for (int i = 0; i < CourseNo; i++) {
total=total+getCourseScore(i); // 累加各门课程成绩
};
average = total / CourseNo;
String currentGrade="";
if (average>=80&&average<100){
currentGrade = "优秀";
}
else if (average>=70&&average<80){
currentGrade = "良好";
}
else if (average>=60&&average<70){
currentGrade = "一般";
}
else if (average>=50&&average<60){
currentGrade = "及格";
}
else{
currentGrade = "不及格";
}
setCourseGrade(currentGrade);
}
}