Class TimesTable


  • public class TimesTable
    extends java.lang.Object
    A class that produces a multiplication table.

    The provided code is incomplete. Modify it so that it works properly and passes the tests in TimesTableTest.java.

    See Also:
    MP2 Documentation
    • Constructor Summary

      Constructors 
      Constructor Description
      TimesTable()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int[][] generateTimesTable(int first, int second)
      Given two positive numbers first and second, produce a multiplication table for numbers first through second, inclusive.
      static void main(java.lang.String[] unused)
      Solicits two integers from the user and print the resulting multiplication table.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TimesTable

        public TimesTable()
    • Method Detail

      • generateTimesTable

        public static int[][] generateTimesTable(int first,
                                                 int second)
        Given two positive numbers first and second, produce a multiplication table for numbers first through second, inclusive.

        For example, if create(4, 6) produces the following 2D array: [[0, 4, 5, 6] [4, 16, 20, 24] [5, 20, 25, 30] [6, 24, 30, 36]]

        Note that:

        • The output array should always start with zero, such that output[0][0] == 0.
        • The output array is symmetric, such that output[n][m] == output[m][n].

        You should reject any values of first and second that are not positive. You should also reject the case where second is not greater than first. In these cases you should return null.

        Parameters:
        first - the number to start the multiplication table at
        second - the number to end the multiplication table at
        Returns:
        the two-dimensional multiplication table, or null if the arguments are invalid
      • main

        public static void main(java.lang.String[] unused)
        Solicits two integers from the user and print the resulting multiplication table.

        You are free to review this function, but should not modify it. Note that this function is not tested by the test suite, as it is purely to aid your own interactive testing.

        Parameters:
        unused - unused input arguments