【课本】学生信息管理

package mypacket;


public class StudentDemo {


public static void main(String[] args) {
// TODO 自动生成的方法存根
Student a=new Student("1015010619","lisiping",78.5f,79f,96f);
System.out.println("学号:"+a.getXuhao());
System.out.println("姓名:"+a.getName());
System.out.println("数学成绩:"+a.getmScore());
System.out.println("英语成绩:"+a.geteScore());
System.out.println("计算机成绩:"+a.getcScore());
System.out.println("平均分:"+a.avg());
System.out.println("最大值:"+a.max());
System.out.println("最小值:"+ a.min());
}


}
class Student{
private String xuhao;
private String name;
private float mScore;
private float eScore;
private float cScore;
public Student(String xuhao,String name,float mScore,float eScore,float cScore){
this.setXuhao(xuhao);
this.setName(name);
this.setmScore(mScore);
this.seteScore(eScore);
this.setcScore(cScore);
}
public String getXuhao(){
return xuhao;
}
public void setXuhao(String n){
this.xuhao=n;
}
public String getName(){
return name;
}
public void setName(String name){
this.name=name;
}
public float getmScore(){
return mScore;
}
public void setmScore(float x){
this.mScore=x;
}
public float geteScore(){
return eScore;
}
public void seteScore(float y){
this.eScore=y;
}
public float getcScore(){
return cScore;
}
public void setcScore(float z){
this.cScore=z;
}
public float avg(){
float avg=(mScore+eScore+cScore)/3;
return avg;
}
public float max(){
float[] arr={mScore,eScore,cScore};
float max=arr[0];
for(int i=0;i<arr.length;i++){
if(max<arr[i]){
max=arr[i];
}
}
return max;
}
public float min(){
/*float[] arr={mScore,eScore,cScore};
float min=arr[0];
for(int i=0;i<arr.length;i++){
if(min>arr[i]){
min=arr[i];
}
}*/
float min=mScore;
min=min<cScore?min:cScore;
min=min<eScore?min:eScore;
return min;
}
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值