首页 > 其他 > 详细

考生类

时间:2019-10-14 16:07:29      阅读:69      评论:0      收藏:0      [点我收藏+]

package paet02;

public class ExampleDemo01 {
public static void main(String[] args) {
Student stu = new Student("MLDN-33","李兴华",95.0f,92.0f,93.0f);
System.out.println("学生编号:"+stu.getStuno());
System.out.println("学生姓名:"+stu.getName());
System.out.println("数学成绩:"+stu.getMath());
System.out.println("英语成绩:"+stu.getEnglish());
System.out.println("计算机成绩:"+stu.getComputer());
System.out.println("最高分:"+stu.max());
System.out.println("最低分:"+stu.min());
System.out.println("总和:"+stu.sum());
System.out.println("平均分:"+stu.avg());
}

}

class Student{
private String stuno;
private String name;
private float math;
private float english;
private float computer;
public String getStuno() {
return stuno;
}
public void setStuno(String stuno) {
this.stuno = stuno;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public float getMath() {
return math;
}
public void setMath(float math) {
this.math = math;
}
public float getEnglish() {
return english;
}
public void setEnglish(float english) {
this.english = english;
}
public float getComputer() {
return computer;
}
public void setComputer(float computer) {
this.computer = computer;
}
public Student() {

}
public Student(String stuno, String name, float math, float english,
float computer) {
setMath(math);
setEnglish(english);
setComputer(computer);
setName(name);
setStuno(stuno);
}
public float sum(){
return math + english + computer;
}
public float avg(){
return (math + english + computer)/3;
}
public float max(){
float max = math;
max = max > english ? max : english;
max = max > computer ? max : computer;
return max;
}
public float min(){
float min = math;
min = min < english ? min : english;
min = min < computer ? min : computer;
return min;
}
}

考生类

原文:https://www.cnblogs.com/wazl/p/11671417.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!