展开全部
定义一个表示学生信息的类Student,要求如下:
(1)类Student的成员变量:
sNO 表示学号;sName表示姓62616964757a686964616fe59b9ee7ad9431333365643637名;sSex表示性别;sAge表示年龄;sJava:表示Java课程成绩。
(2)类Student带参数的构造方法:
在构造方法中通过形参完成对成员变量的赋值操作。
(3)类Student的方法成员:
getNo():获得学号;
getName():获得姓名;
getSex():获得性别;
getAge()获得年龄;
getJava():获得Java 课程成绩
(4)根据类Student的定义,创建五个该类的对象,输出每个学生的信息,计算并输出这五个学生Java语言成绩的平均值,以及计算并输出他们Java语言成绩的最大值和最小值。*/
class student{
String sNO,sName,sSex;
int sAge;
double sJava;
public student(String a,String b,String c,int d ,double e){
sNO=a;
sName=b;
sSex=c;
sAge=d;
sJava=e;}
String getNo(){
return sNO;}
String getName(){
return sName;}
String getSex(){
return sSex;}
int getAge(){
return sAge;}
double getJava(){
return sJava;}
void show(){
System.out.println("姓名:"+getName());
System.out.println("学号:"+getNo());
System.out.println("性别:"+getSex());
System.out.println("年龄:"+getAge());
System.out.println("Java成绩:"+getJava());}
}
public class chengji{
public static void main(String[] args){
double avrage,K1,K2,K3,K4,K5;
student A1=new student("13190310","李一","男",18,80);
student A2=new student("13190311","刘二","女",19,83);
student A3=new student("13190312","张三","男",19,82);
student A4=new student("13190313","杨四","女",20,88);
student A5=new student("13190314","韩舞","女",20,90);
A1.show();
System.out.println();
A2.show();
System.out.println();
A3.show();
System.out.println();
A4.show();
System.out.println();
A5.show();
System.out.println();
K1=A1.getJava();
K2=A2.getJava();
K3=A3.getJava();
K4=A4.getJava();
K5=A5.getJava();
avrage=(K1+K2+K4+K3+K5)/5;
System.out.println("Java平均成绩:"+avrage);
double a[]={K1,K2,K3,K4,K5};
double max=0,min=0,ck;
for(int i=0;i<4;i++){
max=K1;
if(max
ck=max;
max=a[i+1];
a[i+1]=ck;}}
System.out.println("Java的最高分为:"+max);
for(int i=0;i<4;i++){
max=K1;
if(min>a[i+1]){
ck=min;
min=a[i+1];
a[i+1]=ck;}
}
System.out.println("Java的最低分为:"+max);
}
}