From 9d53d8857eaa1c9405894a88ca75bc4657e42f35 Mon Sep 17 00:00:00 2001 From: msglm Date: Sat, 14 Jan 2023 05:31:48 -0600 Subject: Inital Commit --- Java/MagicSquare/Main.java | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Java/MagicSquare/Main.java (limited to 'Java/MagicSquare/Main.java') diff --git a/Java/MagicSquare/Main.java b/Java/MagicSquare/Main.java new file mode 100644 index 0000000..6fb1f19 --- /dev/null +++ b/Java/MagicSquare/Main.java @@ -0,0 +1,25 @@ +import java.util.Scanner; + +class Main{ + public static void main(String[] args) { + Scanner sc = new Scanner (System.in); + System.out.println("enter size of square, must be odd"); + + int size = sc.nextInt(); + + while(size % 2 == 0){ + System.out.println("not odd"); + size = sc.nextInt(); + } + + MagicSquare mSquare = new MagicSquare(size); + + int[][] sq = mSquare.mSquare; + for (int i = 0; i < sq.length; i++){ + for(int j = 0; j < sq[i].length; j++){ + System.out.print(sq[i][j] + " "); + } + System.out.println(); + } + } + } -- cgit v1.2.3