Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a Java console program that prompts a user to enter a number. The program

ID: 3817686 • Letter: C

Question

Create a Java console program that prompts a user to enter a number. The program uses the input value to calculate and list the products of two numbers up to the entered number. For instance, if a user has entered 3, the program calculates the products between two numbers (e.g., 1 times 1, 1 times 2, 1 times 3, 2 times 1, 2 times 2, 2 times 3, 3 times 1, 3 times 2, and 3 times 3), stores the products into a two-dimensional array, and list the multiplied numbers. The program then asks the user whether to continue or quit. If the user enters q, the program stops. If the user enters any other key but q, the program continues as shown in the following example. C:Java Code>java Exam04TomJones Enter a positive integer: 3 Enter q to quit or any other key to continue: c Enter a positive integer: 4 Enter q to quit or any other key to continue: q C:Java Code>

Explanation / Answer

import java.util.Scanner;

public class Demo {

   public static void main(String[] args) {

  

       Scanner reader = new Scanner(System.in);

       System.out.print("Enter a number: ");

       int n = reader.nextInt();

       Integer[][] arr = new Integer[n][n];

       for(int i=0; i<n; i++){

           for(int j=0; j<n; j++){

               arr[i][j] = (i+1) * (j+1);

               System.out.print(arr[i][j]+" ");

           }

           System.out.println(" ");

       }

   }

}