Question: Hello, I had a chat session but we had difficulty with audio. Can someone please comment out all the lines of code for this magic

Hello, I had a chat session but we had difficulty with audio. Can someone please comment out all the lines of code for this magic square program? Thank you.

mport java.io.*; import java.util.*;

public class Magic { static void generateSquare(int n, int ch) { int[][] magicSquare = new int[n][n]; int i = n/2; int j = n-1;

for (int num=1; num <= n*n; ) { if (i==-1 && j==n) { j = n-2; i = 0; } else { if (j == n) j = 0; if (i < 0) i=n-1; }

if (magicSquare[i][j] != 0) { j -= 2; i++; continue; } else magicSquare[i][j] = num++;

j++; i--; }

if (ch == 0) { for(i=0; i

public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = 0; do { System.out.println("Enter number of sides : "); n = sc.nextInt(); if (n == 2) System.out.println("Not Possible"); if (n == 6 || n == 10 || n==14) System.out.println("Don't press your luck"); } while (n == 2 || n== 6 || n==10 || n==14 || n < 1 || n > 17); System.out.println("with box-1 && without box-0 "); int choice = sc.nextInt(); generateSquare(n, choice); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!