我的 java 项目作业有问题。在这个程序中,当我使用案例 1 时,它会激活学生录音系统。我需要我必须用方法编写所有这些记录系统。我试过但我失败了。你能告诉我如何编写将信息记录到数组的方法吗?非常感谢 。
//===========================================values
String[] name = new String [100];
String[] gender = new String [100];
String[] studentNo = new String [100];
Double[] gpa = new Double [100];
int menu = 0;
int accountNumber = 0;
//===========================================
menu = in.nextInt();
switch (menu)
case 1: {
System.out.println("** Recording a new student");
System.out.println("*** Please use lower case");
in.nextLine(); // for solve skipping
System.out.print("Enter Student Name and Surname: ");
name[accountNumber] = in.nextLine();
System.out.print("Enter Student Gender(m/f): ");
gender[accountNumber] = in.nextLine();
System.out.print("Enter Student Number: ");
studentNo[accountNumber] = in.nextLine();
System.out.print("Enter Student GPA: ");
gpa[accountNumber] = in.nextDouble();
accountNumber++;
System.out.println("New Student Recorded. There are ["+accountNumber+"] students in system.");
System.out.println("");
}break;