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

Java Help Create a multiplication table for numbers 1 – 9,and all the multiples

ID: 3675378 • Letter: J

Question

Java Help

Create a multiplication table for numbers 1 – 9,and all the multiples up to 9.

Use a Nested for Loop to print the table.

Formatting is key your output should exactly match the output below.

Expected Output

Multiplication Table

    1    2    3    4    5    6    7    8    9

---------------------------------------------------------

1|    1    2    3    4    5    6    7    8    9

2|    2    4    6    8    10    12    14    16    18

3|    3    6    9    12    15    18    21    24    27

4|    4    8    12    16    20    24    28    32    36

5|    5    10    15    20    25    30    35    40    45

6|    6    12    18    24    30    36    42    48    54

Etc...

Explanation / Answer

/* Prints multiplication table in Java */

public class FullMultiplicationTable {

               public static void main(String[] args) {

              int tableSize = 9;

              printMultiplicationTable(tableSize);

           }

         public static void printMultiplicationTable(int tableSize) {

       // first print the top header row

      System.out.format("      ");

     for(int i = 1; i<=tableSize;i++ ) {

             System.out.format("%4d",i);

    }

        System.out.println();

System.out.println("------------------------------------------");

for(int i = 1 ;i<=tableSize;i++) {

    // print left most column first

            System.out.format("%4d |",i);

            for(int j=1;j<=tableSize;j++) {

               System.out.format("%4d",i*j);

            }

         System.out.println();

   }

   }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote