Write a class named Add that has the following data members, constructor, and me
ID: 3620984 • Letter: W
Question
Write a class named Add that has the following data members, constructor, and methods:Data Members:
private int row; // The number of rows for the addition table.
private int column; // The number of columns for the addition table.
Constructor:
// Sets the values of the above data members.
public Add ( )
Methods:
// Prompt the user to enter the number of rows in their addition table.
// This value should be chosen from 2 to 30, and if the user enters a value
// outside of this range, they should be prompted again.
public void GetRows ( )
// Prompt the user to enter the number of columns in their addition table.
// This value should be chosen from 2 to 12, and if the user enters a value
// outside of this range, they should be prompted again.
public void GetColumns ( )
// Print out the addition table with the user-defined number of rows and
// columns. Your table should have row and column headings.
public void PrintAddTable ( )
Assignment:
1. Implement a class Add with the following properties.
a. An Add keeps track of the values row and column.
b. The initial values for row and column are specified in the constructor.
c. Supply the methods GetRows, GetColumns, and PrintAddTable as described above.
2. Use the following main method:
public static void main ( String [] args ) {
Add table = new Add ( );
table.GetRows ( );
table.GetColumns ( );
table.PrintAddTable ( );
}
3. See the 4 sample run outputs on the following pages:
________________________________________________________________________
Enter the number of rows to be shown ( 2 - 30 ) -> 4
Enter the number of columns to be shown ( 2 - 12 ) -> 7
Here is your table:
| 1 2 3 4 5 6 7
-------------------------------------------------------------------
1 | 2 3 4 5 6 7 8
2 | 3 4 5 6 7 8 9
3 | 4 5 6 7 8 9 10
4 | 5 6 7 8 9 10 11
________________________________________________________________________
Explanation / Answer
This is the answer.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.