用JAVA定义?
定义一个学生类Student,成员变量有9个,分别是学号、姓名、性别、年龄、班级、计算机网络基础课程成绩、嵌入式面向对象编程(Java)课程成绩、MySQL数据库课程成绩...
定义一个学生类Student,成员变量有9个,分别是学号、姓名、性别、年龄、班级、计算机网络基础课程成绩、嵌入式面向对象编程(Java)课程成绩、MySQL数据库课程成绩、面向对象计算思维APP Inventor课程成绩,成员方法包括setters和getters、求课程总成绩和求课程平均分。
展开
1个回答
2020-03-26
展开全部
public class Student {
private String id; //学号
private String name; //姓名
private String gender; //性别
private int age; //年龄
private String classroom; //班级
private double internet; //计算机网络基础课程成绩
private double java; //嵌入式面向对象编程(Java)课程成绩
private double mysql; //MySQL数据库课程成绩
private double inventor; //面向对象计算思维APP Inventor课程成绩
//求课程的总成绩
public void ShowGrade() {
double grade = getInternet() + getJava() + getMysql() + getInventor();
System.out.println("四门功课的总成绩:" + grade);
System.out.println("平均成绩:" + grade / 4);
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getClassroom() {
return classroom;
}
public void setClassroom(String classroom) {
this.classroom = classroom;
}
public double getInternet() {
return internet;
}
public void setInternet(double internet) {
this.internet = internet;
}
public double getJava() {
return java;
}
public void setJava(double java) {
this.java = java;
}
public double getMysql() {
return mysql;
}
public void setMysql(double mysql) {
this.mysql = mysql;
}
public double getInventor() {
return inventor;
}
public void setInventor(double inventor) {
this.inventor = inventor;
}
}
private String id; //学号
private String name; //姓名
private String gender; //性别
private int age; //年龄
private String classroom; //班级
private double internet; //计算机网络基础课程成绩
private double java; //嵌入式面向对象编程(Java)课程成绩
private double mysql; //MySQL数据库课程成绩
private double inventor; //面向对象计算思维APP Inventor课程成绩
//求课程的总成绩
public void ShowGrade() {
double grade = getInternet() + getJava() + getMysql() + getInventor();
System.out.println("四门功课的总成绩:" + grade);
System.out.println("平均成绩:" + grade / 4);
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getClassroom() {
return classroom;
}
public void setClassroom(String classroom) {
this.classroom = classroom;
}
public double getInternet() {
return internet;
}
public void setInternet(double internet) {
this.internet = internet;
}
public double getJava() {
return java;
}
public void setJava(double java) {
this.java = java;
}
public double getMysql() {
return mysql;
}
public void setMysql(double mysql) {
this.mysql = mysql;
}
public double getInventor() {
return inventor;
}
public void setInventor(double inventor) {
this.inventor = inventor;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询