use java to solve Create a class MagicSquare that prompts the user for a positive odd integer size, generates a normal magic square of order size, and prints it with numbers right-justified and aligned in evenly-spaced columns. You may assume the numbers in the square are 3 digits or less (i.e. size ≤ 31). However, each space-separated column should have a width equal to the largest integer in the magic square. (See example transcripts below.) To generate the magic square, use the following algorithm: Assign 1 to our initial current position: the bottom row, middle column. Place each successive value (up to size * size) in the first of the following positions that is unoccupied: (1) one space down and to the right, or (2) one space up. Positions wrap around the sides, top and bottom, as shown in the following example transcripts (user input underlined):
use java to solve
Create a class MagicSquare that prompts the user for a positive odd integer size, generates a normal magic square of order size, and prints it with numbers right-justified and aligned in evenly-spaced columns. You may assume the numbers in the square are 3 digits or less (i.e. size ≤ 31). However, each space-separated column should have a width equal to the largest integer in the magic square. (See example transcripts below.)
To generate the magic square, use the following
Step by step
Solved in 2 steps with 2 images