I already have a class called Card that represents a standardplaying card deck.
ID: 3617699 • Letter: I
Question
I already have a class called Card that represents a standardplaying card deck. Each card has a suit and a face value.I need to write a program that reads a number n and then reads n*nintegers into an n-by-n two dimensional array and checks to see ifthe numbers form a magic square. In a magic square, the sum of allthe elements in every row, column and along both diagonals is thesame. I already have a class called Card that represents a standardplaying card deck. Each card has a suit and a face value.
I need to write a program that reads a number n and then reads n*nintegers into an n-by-n two dimensional array and checks to see ifthe numbers form a magic square. In a magic square, the sum of allthe elements in every row, column and along both diagonals is thesame.
Explanation / Answer
please rate - thanks import java.util.*; import java.text.*; public class untitled {public static void main(String[] args) {DecimalFormat threedigit = new DecimalFormat("#00 "); String formattednumber; int x=0,y,n,i,j,k=1,tot=0,total=0; boolean yes=true; Scanner in=new Scanner(System.in); do{ System.out.println("How large isyour square? "); n=in.nextInt(); if(n%2==0) System.out.println("Must be an odd number and > 0! -retry"); }while(n%2!=1); int [][]square = new int[n][n]; for(i=0;iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.