public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
StudentManager manager = new StudentManager(5);
while (true) {
System.out.println("");
System.out.println("石家庄铁道大学软件工程系学生信息管理系统");
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("6、退出系统;");
System.out.print("请选择操作:");
int choice = scanner.nextInt();
scanner.nextLine();
switch (choice) {
case 1:
manager.showStudents();
break;
case 2:
System.out.print("请输入学号:");
String stunumber = scanner.nextLine();
System.out.print("请输入姓名:");
String name = scanner.nextLine();
System.out.print("请输入年龄:");
int age = scanner.nextInt();
System.out.print("请输入性别(男输入0,女输入1):");
boolean sex = scanner.nextInt() == 1;
System.out.print("请输入成绩:");
double score = scanner.nextDouble();
manager.addStudent(stunumber, name, age, sex, score);
break;
case 3:
System.out.print("请输入要删除的学号:");
String deleteStunumber = scanner.nextLine();
manager.deleteStudent(deleteStunumber);
break;
case 4:
System.out.print("请输入要修改的学号:");
String updateStunumber = scanner.nextLine();
System.out.print("请输入新姓名:");
String newName = scanner.nextLine();
System.out.print("请输入新年龄:");
int newAge = scanner.nextInt();
System.out.print("请输入新性别(男输入0,女输入1):");
boolean newSex = scanner.nextInt() == 1;
System.out.print("请输入新成绩:");
double newScore = scanner.nextDouble();
manager.updateStudent(updateStunumber, newName, newAge, newSex, newScore);
break;
case 5:
System.out.print("请输入要查询的学号:");
String selectStunumber = scanner.nextLine();
manager.selectStudent(selectStunumber);
break;
case 6:
System.out.println("退出系统。");
scanner.close();
return;
default:
System.out.println("无效选择,请重试。");
}
}
}
}
标签:20,scanner,2024.9,System,println,print,输入,out From: https://www.cnblogs.com/yangsongduo/p/18423426