/*学生类:
成员属性:
学号:sNO
姓名:sName
性别:sSex
年龄:sAge
成绩:sJava
构造方法:
1,构造函数,需要完成成员变量的赋值操作。
成员方法:
1,getNo();获得学号;
2,getName();获得姓名;
3,getSex();获得性别;
4,getAge();获得年龄;
5,getJava();获得Java课程成绩。
创建5个Student的对象。
1,输出每个学生的信息。
2,计算并输出这五个学生Java语言成绩的平均值。
以及计算并输出他们Java语言成绩的最大值和最小值。*/
classStudent
{//成员属性;
int sNO;//学号
String sName;//姓名
char sSex;//性别
int sAge;//年龄
double sJava;//成绩//构造方法
Student(int sNO,String sName,char sSex,int sAge,doublesJava)
{this.sNO =sNO;this.sName =sName;this.sSex =sSex;this.sAge =sAge;this.sJava =sJava;
}//成员方法
intgetNo()
{returnsNO;
}
String getName()
{returnsName;
}chargetSex()
{returnsSex;
}intgetAge()
{returnsAge;
}doublegetJava()
{returnsJava;
}
}classStuTest
{public static voidmain(String[] args)
{
Student s1= new Student(110,"张三",'M',18,85.5);
System.out.println("stu_1:学号:"+s1.getNo()+",姓名:"+s1.getName()+",性别:"+s1.getSex()+",年龄:"+s1.getAge()+",Java成绩:"+s1.getJava());
Student s2= new Student(111,"李四",'M',20,78);
System.out.println("stu_2:学号:"+s2.getNo()+",姓名:"+s2.getName()+",性别:"+s2.getSex()+",年龄:"+s2.getAge()+",Java成绩:"+s2.getJava());
Student s3= new Student(112,"王五",'M',19,86);
System.out.println("stu_3:学号:"+s3.getNo()+",姓名:"+s3.getName()+",性别:"+s3.getSex()+",年龄:"+s3.getAge()+",Java成绩:"+s3.getJava());
Student s4= new Student(113,"李芸",'F',18,90);
System.out.println("stu_4:学号:"+s4.getNo()+",姓名:"+s4.getName()+",性别:"+s4.getSex()+",年龄:"+s4.getAge()+",Java成绩:"+s4.getJava());
Student s5= new Student(114,"李刚",'M',19,80);
System.out.println("stu_5:学号:"+s5.getNo()+",姓名:"+s5.getName()+",性别:"+s5.getSex()+",年龄:"+s5.getAge()+",Java成绩:"+s5.getJava());double aver = (s1.getJava()+s2.getJava()+s3.getJava()+s4.getJava()+s5.getJava())/5;
System.out.println("average="+aver);//Scanner in = new Scanner(System.in);
double[] x = new double[5];
x[0] =s1.getJava();
x[1] =s2.getJava();
x[2] =s3.getJava();
x[3] =s4.getJava();
x[4] =s5.getJava();double max = x[0];double min = x[0];for(int i=1;i<5;i++)
{if(x[i]>max)
max=x[i];
}for(int i=1;i<5;i++)
{if(x[i]
min=x[i];
}
System.out.println("max="+max+",min="+min);
}
}