Question: (b) Design and implement a Java program that will ask the user for the required number of rows and columns, and then generate a neatly

(b) Design and implement a Java program that will ask the user for the required number of rows and columns, and then generate a neatly laid out table, with each cell indicating the "row,col" values, as in the following example (a table having 3 rows and 4 columns):

 1,1 1,2 1,3 1,4 2,1 2,2 2,3 2,4 3,1 3,2 3,3 3,4 

Note that the cell contents are aligned to the right of a 6 character wide cell. Rather than rely on tabs for such spacing, write a loop that will add space characters to the output data so as to align it within a given column width.

Copy-paste the relevant segment of your code four times, such that your program produces four tables (precede each by an appropriate title), and then modify the copies so they each display one of the following:

the row & column numbers as shown in the example

the product of the row & column number (a multiplication table!)

the cell number beginning from 0 and increasing left to right, top to bottom (i.e. 0,1,2,3 on the first row, 4,5,6,7 on the next, and so on).

the row number in the first column only, putting the String "-" into the other cells. (i.e. 1,-,-,- on the first row, 2,-,-,- on the second, and so on).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!