我在寫一個Java程序,要求用戶輸入每個學生的標記(對於2個科目)(總共4名學生)。基本上,這是一個二維數組操作。在Java中接受二維數組作爲輸入
我被困在需要用戶輸入輸入的地步。我在想input.nextInt()的普通方法不起作用。這是我的代碼到目前爲止。有人可以幫忙嗎?
package Chapter2_Arrays;
import java.util.*;
public class Arrays_ExTwo {
static final int numberOfSubjects=2;
static final int numberOfStudents=4;
static int [][] marks=new int[numberOfSubjects][numberOfStudents];
static Scanner in=new Scanner(System.in);
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Welcome to Cincinnati Elementary");
System.out.println("There are "+ " "+ numberOfSubjects+ " "+ "subjects being taught");
System.out.println("There are "+" "+numberOfStudents+" "+" number of students in the class");
System.out.println("Enter the subject number followed by the marks of all the students for the subject");
for(int i=0;i<numberOfSubjects;i++)
{
for(int j=0;j<numberOfStudents;j++)
{
marks[i][j]=in.
}
}
}
}
爲什麼你認爲'in.nextInt()'將無法正常工作?你試過了嗎? – Keppil
顯示您想要輸入的格式... – Devavrata