class Student {

private String name;

private int age;

private String gender;

private double english;

private double math;

private double chinese;

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public int getAge() {

return age;

}

public void setAge(int age) {

this.age = age;

}

public String getGender() {

return gender;

}

public void setGender(String gender) {

this.gender = gender;

}

public double getEnglish() {

return english;

}

public void setEnglish(double english) {

this.english = english;

}

public double getMath() {

return math;

}

public void setMath(double math) {

this.math = math;

}

public double getChinese() {

return chinese;

}

public void setChinese(double chinese) {

this.chinese = chinese;

}

public void study() {

System.out.println("这位学生的姓名是:" + getName() + "\n\t" + "年龄:" + getAge() + "\n\t" + "性别:" + getGender() + "\n\t" + "英语成绩:" + getEnglish() + "\n\t" + "数学成绩:" + getMath() + "\n\t" + "语文成绩:" + getChinese() + "\n\t");

}

public void sum() {

System.out.println("\t" + "总成绩:" + (getEnglish() + getMath() + getChinese()));

}

public void average() {

System.out.println("\t" + "平均分:" + (getEnglish() + getMath() + getChinese())/3);

}

}

Logo

欢迎加入 MCP 技术社区!与志同道合者携手前行,一同解锁 MCP 技术的无限可能!

更多推荐