Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hello, separated questions on this assignment I need help on, to be done in JAVA AP COMPUTER SCIENCE A EXTRA PRACTICE FOR 2D ARRAYS For
Hello, separated questions on this assignment I need help on, to be done in JAVA
AP COMPUTER SCIENCE A EXTRA PRACTICE FOR 2D ARRAYS For this set of problems, you will have the freedom to show evidence of your planning in any way you see fit. We have already covered pseudocode, flowcharts, and truth tables as common methods for planning code prior to writing code. For each of these exercises, develop a plan BEFORE you begin coding. Once you begin coding, be sure to comment your code. You may need to implement multiple methods. If you choose to write pseudocode, you may use the lines of pseudocode as the comments for your code to show how it was translated. 3. Magic squares. An nxn matrix that is filled with the numbers 1, 2, 3,...,n? is a magic square if the sum of the elements in each row, in each column, and in the two diagonals is the same value. Write a program that reads in 16 values from the user, places them into a 4 x 4 matrix, and tests whether they form a magic square (placing them into rows - So the first 4 ints is the first row of the square). You need to implement two methods and test two features: 1. Do each of the numbers 1, 2, ..., 16 occur once in the user input? If not, you do not need to check part 2. public static boolean allSixteen (int[] [] nums) 2. When the numbers are put into a square, do the numbers form a magic square? That is - are the sums of the rows, columns, and diagonals equal to each other? public static boolean isSquareMagic (int[] [] nums) This should print the formatted number square and whether the square is a magic square. SAMPLE: This input IS a magic square: 16 2 3 13 5 11 10 8 9 7 6 12 4 14 15 1 This input IS NOT a magic square: 16 9 6 3 5 4 15 10 11 14 2 8 1 7 12 13Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started