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

Enter into a sentinel controlled query loop that prompts the user to enter how m

ID: 659190 • Letter: E

Question

Enter into a sentinel controlled query loop that prompts the user to enter how many rows and columns they want to see in a multiplication table.

Based on the user inputs, generate and print the appropriate multiplication table. If the user enters -99 for the number of rows or the number of columns, then print the total number of tables generated and terminate the program.

Print an error message to the standard error stream if any of the following are true:

number of rows is less than 1 (and not equal the sentinel value)

number of rows is greater than 16

number of columns is less than 1

number of columns is greater than 12

[Note: be sure you use manifest constants.]

Print headings along the top and down the side of each table.

You are required to use all three repetition control statements in this program (i.e. your program must have at least one for() statement, one while() statement, and one do-while()statement).

Use a comment block to express your program in pseudo-code.

Your multiplication tables must be nicely formatted (i.e. fixed column widths). I wrote a method named pad() to help you accomplish this. [The method is a tool for you to use. Learning about programming requires you to acquire a collection of tools that help you do your computing.]

Example Output

Assume user inputs are in brackets <>.

Explanation / Answer

import java.util.Scanner; class Tables { public static void main(String args[]) { int a, b, c, d; System.out.println("Enter range of numbers to print their multiplication table"); Scanner in = new Scanner(System.in); a = in.nextInt(); b = in.nextInt(); for (c = a; c