该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
package com.task02;
import java.util.Arrays;
class Student{
private String name; //声明封装name性性
private int stuno;
private float math;
private float english;
private float computer;
public Student(){}
public Student(String name,int stuno,float math,float english,float computer){
this.name=name;
this.stuno=stuno;
this.math=math;
this.english=english;
this.computer=computer;
}
public void setName(String name){
this.name=name;
}
public void setStuno(int stuno){
this.stuno=stuno;
}
public void setMath(float math){
this.math=math;
}
public void setEnglish(float english){
this.english=english;
}
public void setComputer(float computer){
this.computer=computer;
}
public String getName(){
return name;
}
public int getStuno(){
return stuno;
}
public float getMath(){
return math;
}
public float getEnglish(){
return english;
}
public float getComputer(){
return computer;
}
public void avg(){
System.out.print((getMath()+getEnglish()+getComputer())/3);
}
public void sum(){
System.out.print(getMath()+getEnglish()+getComputer());
}
}
public class Test{
public static void main(String args[]){
Student nam=new Student();
Student stun=new Student();
Student mat=new Student();
Student englis=new Student();
Student compute=new Student();
Student x=new Student();
Student y=new Student();
nam.setName("tom");
stun.setStuno(55);
mat.setMath(78);
englis.setEnglish(99);
compute.setComputer(69);
int j[]=new int[]{78,99,69};
Arrays.sort(j);
System.out.print("名字:"+nam.getName());
System.out.print(";学号:"+stun.getStuno());
System.out.print(";平均分:");
y.avg();
System.out.print("总分:");
x.sum();
System.out.print(";最高分:"+j[2]);
System.out.print(";最低分:"+j[0]);
}
}