Write a class MultiplicationTable
that creates a 2-dimensional, 11-by-13 array products that stores the products of the values row
× col
, where row runs from 0
to 10
inclusive, and col runs from 0
to 12
inclusive.
The table should be created when the object is constructed.
Write a lookup()
method that takes a row
and column
as parameters and returns the entry stored at [row][col]
as listed in the table, ie. the product of those values. If an illegal column or row is sent as a parameter, the lookup()
method should return an error-indicating result of -1
.
Include a display()
method that prints out the entire table. It's useful to use printf
formatting to align the columns of the table.
In addition to the table itself, have the display
method print out the row values along the left side of the table, and the column values across the top of the table.