I am new to Java. I have to show to terminal int coefficients from a 2D array. I would like to have each value for the same seller in the same line. There is a line break (due to Scanner ?). I have been looking for delimiter for system.in but I do not understand how to use it and if that is appropriate.
Please, may you help me ? Thank you in advance
import java.util.Scanner;
public class Ventes {
public static void main(String[] args) {
Scanner myObj = new Scanner(System.in);
System.out.print("Enter the number of sellers ");
int nbrSellers = myObj.nextInt();
System.out.print("Enter the number of models ");
int nbrModels = myObj.nextInt();
int[][] sales = new int[nbrSellers][nbrModels];
for(int i = 1; i <= nbrSellers; i++) {
System.out.print("Seller " + i + " ");
for(int j = 0; j < nbrModels; j++) {
sales[i][j] = myObj.nextInt();
}
System.out.println();
}
}
}
Terminal result :
Enter the number of sellers 5
Enter the number of models 4
Seller 1 0
3
2
0