Exercise: Squares

Write a console program that prints the square number of the numbers 1 to 10.

Your program should produce this exact output:

1 * 1 = 1
2 * 2 = 4
3 * 3 = 9
4 * 4 = 16
5 * 5 = 25
6 * 6 = 36
7 * 7 = 49
8 * 8 = 64
9 * 9 = 81
10 * 10 = 100

Hint 💡

You can multiply numbers in Java using the * operator. For example, 3 * 3 will produce the number 9.

Hand in instructions

  1. Make sure your program runs correctly.
  2. Hand in your program by uploading Main.java to Moodle.