java设计 定义并测试一个名为Student的类

1个回答

  • />public class Student

    {

    private String stuNo;

    private String stuName;

    private int sxCj;

    private int yuCj;

    private int jsjCj;

    public Student(String stuNo,String stuName,int sxCj,int yuCj,int jsjCj)

    {

    this.stuNo = stuNo;

    this.stuName = stuName;

    this.sxCj = sxCj;

    this.yuCj = yuCj;

    this.jsjCj = jsjCj;

    }

    public int zongfen()

    {

    return sxCj + yuCj + jsjCj;

    }

    public String getStuNo()

    {

    return stuNo;

    }

    public String getStuName()

    {

    return stuName;

    }

    public int junfen()

    {

    return zongfen() / 3;

    }

    public int maxFenshu()

    {

    return Math.max(Math.max(sxCj, yuCj), jsjCj);

    }

    public int minFenshu()

    {

    return Math.min(Math.min(sxCj, yuCj), jsjCj);

    }

    public static void main(String[] args)

    {

    Student a = new Student("111", "LIMing", 88, 99, 80);

    System.out.println("学号:" + a.getStuNo());

    System.out.println("姓名:" + a.getStuName());

    System.out.println("总分:" + a.zongfen());

    System.out.println("均分:" + a.junfen());

    System.out.println("最高分:" + a.maxFenshu());

    System.out.println("最低分:" + a.minFenshu());

    }

    }