package zuoye2;
import java.util.Scanner;
public class Stu {
public static void main(String[] args) {
System.out.println("请输入要查找的学生名字:");
Scanner scanner=new Scanner(System.in);
String Preson=scanner.next();
StudentManager[]student=new StudentManager[5];
student[0]=new StudentManager(01,"李1",28,89,30);
student[1]=new StudentManager(02,"罗2",64,44,45);
student[2]=new StudentManager(03,"张3",74,56,17);
student[3]=new StudentManager(04,"卢4",55,68,97);
student[4]=new StudentManager(05,"王5",97,38,73);
int num1 = 0;
int num2 = 0;
int num3 = 0;
if (Preson.contains("李1")) {
System.out.println(student[0]);
}
if (Preson.contains("罗2")) {
System.out.println(student[1]);
}
if (Preson.contains("张3")) {
System.out.println(student[2]);
}
if (Preson.contains("卢4")) {
System.out.println(student[3]);
}
if (Preson.contains("王5")) {
System.out.println(student[4]);
}
System.out.print("英语成绩不及格的人:");
for(int i=0;i<student.length;i++){
if(student[i].getEnglishscore()<=60){
System.out.print(student[i].getName()+",");
num1=num1+1;
}
}
System.out.println("合计有 "+num1+"人。");
System.out.print("体育成绩不及格的人:");
for(int i=0;i<student.length;i++){
if(student[i].getPescore()<=60){
System.out.print(student[i].getName()+",");
num2=num2+1;
}
}
System.out.println("合计有 "+num2+"人。");
System.out.print("数学成绩不及格的人:");
for(int i=0;i<student.length;i++){
if(student[i].getMathscore()<=60){
System.out.print(student[i].getName()+",");
num3=num3+1;
}
}
System.out.println("合计有 "+num3+"人。");
}
}
package zuoye2;
public class StudentManager {
private int Sno;
public String Name;
private int Englishscore;
private int PEscore;
private int Mathscore;
public StudentManager(int Sno,String Name,int Englishscore,int PEscore,int Mathscore){
this.Sno=Sno;
this.Name=Name;
this.Englishscore=Englishscore;
this.PEscore=PEscore;
this.Mathscore=Mathscore;
}
public int getSno() {
return Sno;
}
public void setSno(int sno) {
this.Sno = sno;
}
public String getName() {
return Name;
}
public void setName(String name) {
this.Name = name;
}
public int getEnglishscore() {
return Englishscore;
}
public void setEnglishscore(int englishscore) {
this.Englishscore = englishscore;
}
public int getPescore() {
return PEscore;
}
public void setPescore(int pescore) {
this.PEscore = pescore;
}
public int getMathscore() {
return Mathscore;
}
public void setMathscore(int mathscore) {
this.Mathscore = mathscore;
}
public String toString(){
return "姓名:"+this.Name+",学号:"+this.Sno+",英语成绩:"+Englishscore+",体育成绩:"+this.PEscore+",数学成绩:"+this.Mathscore;
}
}