学生类

public class Student {
private String name;
private String number;
private double Escore;
private double Mscore;
private double PEscore;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public double getEscore() {
return Escore;
}
public void setEscore(int escore) {
Escore = escore;
}
public double getMscore() {
return Mscore;
}
public void setMscore(int mscore) {
Mscore = mscore;
}
public double getPEscore() {
return PEscore;
}
public void setPEscore(int pEscore) {
PEscore = pEscore;
}
//构造方法
public Student(String name, String number, double escore, double mscore, double pEscore) {
super();
this.name = name;
this.number = number;
Escore = escore;
Mscore = mscore;
PEscore = pEscore;
}
@Override
public String toString() {
return “Student [name=” + name + “, number=” + number + “, Escore=” + Escore + “, Mscore=” + Mscore
+ “, PEscore=” + PEscore + “]”;
}

}

public class StudentManager {
private static Student[] stu = null;
//根据姓名查成绩
public static void search(String name){
for(int i=0;i<stu.length;i++){
if(stu[i].getName().contains(name)){
System.out.println(stu[i]);
}
}
}
//查询英语不及格人数
public static void searchfail(){
System.out.println(“英语不及格的有:”);
int a=0;
for(int i=0;i<stu.length;i++){
if(stu[i].getEscore()<60){
System.out.print(stu[i].getName()+":"+stu[i].getEscore()+"\t");
a++;
}
}
System.out.println(“共有”+a+“人”);
System.out.println();

	//查询数学不及格人数
	System.out.println("数学不及格的有:");
	int b=0;
	for(int i=0;i<stu.length;i++){
		if(stu[i].getMscore()<60){
			System.out.print(stu[i].getName()+":"+stu[i].getMscore()+"\t");
			b++;
		}
	}
	System.out.println("共有"+b+"人");
	System.out.println();
	//查询体育不及格的人数
	System.out.println("体育不及格的有:");
	int c=0;
	for(int i=0;i<stu.length;i++){
		if(stu[i].getPEscore()<60){
			System.out.print(stu[i].getName()+":"+stu[i].getPEscore()+"\t");
			c++;
		}
	}
	System.out.println("共有"+c+"人");
	System.out.println();
	
}

public static void main(String[] args){
	stu=new Student[5];
	stu[0]=new Student("张三","101",35,93,77);
	stu[1]=new Student("李四", "102", 58, 59, 59);
	stu[2]=new Student("王五", "103", 85, 99, 88);
	stu[3]=new Student("张三丰", "104", 59, 85, 59);
	stu[4]=new Student("张无忌", "105", 74, 88, 91);

// search(“张”);
searchfail();
}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值