package com.geminno.he0126;
import java.util.Scanner;
public class StudentMenu {
public static final int MAX = 100;
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int input;
String[] data1 = new String[MAX];
String[] data2 = new String[MAX];
String[] data3 = new String[MAX];
int count1 = 0;
int count2 = 0;
int count3 = 0;
do {
System.out.println("*****************************");
System.out.println("| 1. 增加学生 |");
System.out.println("| 2. 删除学生 |");
System.out.println("| 3. 查找学生 |");
System.out.println("| 4. 显示学生 |");
System.out.println("| 5. 退出程序 |");
System.out.println("| 请输入选择(1-5): |");
System.out.println("*****************************");
System.out.print("请输入:");
input = s.nextInt();
switch (input) {
case 1:
System.out.print("请输入学生的姓名:");
String name = s.next();
data1[count1 ++] = name;
System.out.print("请输入学生的性别:");
String sex = s.next();
data2[count2 ++] = sex;
System.out.print("请输入学生的成绩:");
String score = s.next();
data3[count3 ++] = score;
System.out.println("增加成功!");
break;
case 2:
System.out.println();
System.out.print("请输入要删除的学生姓名:");
String dname=s.next();
boolean flag=false;
for(int i=0;i
if(data1[i].equals(dname)){
for(int j=i;j
data1[j]=data1[j+1];
}flag=true;
count1--;
System.out.println("删除成功!");
}
}
if(!flag){
System.out.println("对不起,没有你要删除的学生姓名!");
}
break;
case 3:
System.out.print("请输入要查找的学生姓名:");
String sname = s.next();
boolean fla = false;
for(int i = 0;i
if(data1[i].equals(sname)){
fla = true;
System.out.println("-----------------------------------");
System.out.println("您查找的学生信息:");
System.out.println("姓名:"+data1[i]+" "+"性别:"+data2[i]+" "+"成绩:"+data3[i]);
System.out.println("-----------------------------------");
}
}
if(!fla){
System.out.println("对不起,查无此人!");
}
break;
case 4:
if(count1 == 0){
System.out.println("无学生信息");
}else{
System.out.println();
System.out.println("学生信息列表如下:");
for(int i = 0; i
System.out.println();
System.out.print("姓名:"+data1[i]+" ");
System.out.print("性别:"+data2[i]+" ");
System.out.println("成绩:"+data3[i]+" ");
System.out.println("-----------------------------------");
}
/*for(int i = 0; i
System.out.print("性别:"+data2[i]+" ");
}
for(int i = 0; i
System.out.println("成绩:"+data3[i]+" ");
}*/
}
break;
case 5:
System.out.println("您已退出系统!");
System.exit(0);
break;
default:
System.out.println("您输入的信息有误,请重新输入!");
}
} while (true);
}
}