代码应该要求每个数组的三个输入:(ID,然后是Name,然后是Major).
ID工作完美,但是当它命名时,它打印出来:
请输入学生姓名:请输入学生姓名:
并且只允许该行的一个输入.然后它进入Major并再次正常工作.所以我最终得到3个ID,2个名字和3个专业.
这是我的代码:
package STUDENT;
import java.util.Scanner;
public class StudentDisplayer {
public static void main(String[] args) {
long[]studentId = {11, 22, 33};
String[] studentName = {"Value1", "Value2", "Value3"};
String[] studentMajor = {"Value1", "Value2", "Value3"};
Scanner inReader = new Scanner(System.in);
/* ----------------------------------------------
Print the information in the parallel arrays
---------------------------------------------- */
for (int i = 0; i < studentId.length; i++ ){
System.out.println("Please enter the student's id: ");
studentId[i] = inReader.nextLong();
}
for (int i = 0; i < studentName.length; …Run Code Online (Sandbox Code Playgroud)