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();
}
}