Problem statement:
I want to write a program that reads in a positive integer n from standard input and creates an n-by-n integer array a[][]
such that a[i][j]
is the product of (i+1)th row with the (j+1)th column.
Current Code:
Scanner input = new Scanner(System.in);
String inputString;
char flag = 'y';
while (flag != 'q' && flag != 'Q') {
System.out.print("Enter a positive integer:");
int value = input.nextInt();
System.out.printf("Enter q to quit or any other key to quit: ");
input.nextLine();
inputString = input.nextLine();
flag = inputString.charAt(0);
}
For example
if the user enters 3 the matrix needs to be 3x3 and have the product of 1 multiplied by 1, 1 multiplied by 2 and 1 multiplied by 3. Then do the same thing for 2 and 3.