Question: Using the code I already have I need help figuring out how to write the diag 2 for a magic square in JAVA. This is
Using the code I already have
I need help figuring out how to write the diag for a magic square in JAVA. This is the code I have so far.
import java.util.;
import java.io;
public class Main
static Scanner inp new ScannerSystemin;
private int square;
private boolean possible;
private int totalSqs;
private int magicConst;
private int numsquares;
public Mainint N
if N
System.out.printOnly give values ;
System.exit;
square new int NN; initialize with zeros by default
magicConst this.findMagicConstantN;
totalSqs NN;
possible new booleantotalSqs;
forint i ; i totalSqs; i
possiblei true;
numsquares ;
public int findMagicConstantint N
int lastnum NN;
int sum lastnum lastnum ;
return sumN;
public void fillint row, int col
if validSquare
System.out.printlnDone;
forint rws: square
System.out.printlnArraystoStringrws;
if row square.length
Systemout.printlnthis;
numsquares;
return;
Systemout.printlntotalSqs;
forint i ; i
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
