java编程题目
答案:1 悬赏:50 手机版
解决时间 2021-11-30 11:13
- 提问者网友:临风不自傲
- 2021-11-30 06:49
java编程题目
最佳答案
- 五星知识达人网友:夜余生
- 2021-11-30 07:05
public class Student{
private String sid;
private String name;
private String sex;
private String sclass;
private Double yuwen;
private Double shuxue;
private Double yingyu;
private Double lishi;
private Double shengwu;
public Student(){
}
public Double calculateTotal(){
return yuwen+shuxue+yingyu+lishi+shengwu;
}
public String show() {
return "Student{" +
"sid='" + sid + '\'' +
", name='" + name + '\'' +
", sex='" + sex + '\'' +
", sclass='" + sclass + '\'' +
", yuwen=" + yuwen +
", shuxue=" + shuxue +
", yingyu=" + yingyu +
", lishi=" + lishi +
", shengwu=" + shengwu +
'}';
}
public String getSid() {
return sid;
}
public void setSid(String sid) {
this.sid = sid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getSclass() {
return sclass;
}
public void setSclass(String sclass) {
this.sclass = sclass;
}
public Double getYuwen() {
return yuwen;
}
public void setYuwen(Double yuwen) {
this.yuwen = yuwen;
}
public Double getShuxue() {
return shuxue;
}
public void setShuxue(Double shuxue) {
this.shuxue = shuxue;
}
public Double getYingyu() {
return yingyu;
}
public void setYingyu(Double yingyu) {
this.yingyu = yingyu;
}
public Double getLishi() {
return lishi;
}
public void setLishi(Double lishi) {
this.lishi = lishi;
}
public Double getShengwu() {
return shengwu;
}
public void setShengwu(Double shengwu) {
this.shengwu = shengwu;
}
}
public class Test {
public static void main(String[] args) {
Student s1 = new Student();
s1.setName("小王");
s1.setSid("001");
s1.setSclass("初三");
s1.setSex("男");
s1.setShengwu(89.3);
s1.setLishi(67.5);
s1.setYingyu(99D);
s1.setShuxue(88.2);
s1.setYuwen(89.2);
Double aDouble = s1.calculateTotal();
System.out.println("学生信息为"+s1.show());
System.out.println("============================================");
System.out.println(s1.getName()+"的总成绩为"+s1.calculateTotal());
}
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯