public class StudentReportCard {
private String studentName;
private int mathScore;
private int englishScore;
private int chineseScore;
public StudentReportCard(String studentName, int mathScore, int englishScore, int chineseScore) {
this.studentName = studentName;
this.mathScore = mathScore;
this.englishScore = englishScore;
this.chineseScore = chineseScore;
}
// 计算总分
public int calculateTotalScore() {
return mathScore + englishScore + chineseScore;
}
// 计算平均分
public double calculateAverageScore() {
return (double) calculateTotalScore() / 3;
}
// 打印成绩单
public void printReportCard() {
System.out.println("学生姓名: " + studentName);
System.out.println("数学成绩: " + mathScore);
System.out.println("英语成绩: " + englishScore);
System.out.println("语文成绩: " + chineseScore);
System.out.println("总分: " + calculateTotalScore());
System.out.println("平均分: " + calculateAverageScore());
}
public static void main(String[] args) {
StudentReportCard student = new StudentReportCard("小明", 90, 85, 95);
student.printReportCard();
}
}