Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This is the code I did for this activity. Everything works fine except I can't figure out a way to make sure the user enters
This is the code I did for this activity. Everything works fine except I can't figure out a way to make sure the user enters only positive integers. EVERYTHING ELSE WORKS. Please add to my code.
import java.util.Scanner; class Arraytwod { public static void main(String []args) { Scanner reader = new Scanner(System.in); System.out.println("Enter 16 numbers POSITIVE integers and we will determine if it is a magic square."); int count=1; int [][] arr= new int[4][4]; for (int r=0; r
Part III: 2-D Arrays A magic square is a two-dimensional array of positive integers such that the sum of each row, column, and diagonal is the same constant The following example is a magic square whose constant is 34: 2 13 5 10 8 16 7 12 15 141 Write a program that takes 16 integers as inputs. The program should determine whether or not the square is a magic square and display the result. Show the grid of numbers (do not worry about making the boxes). Do not allow the user to enter in negative numbers. You should keep asking until all 16 numbers are positiveStep 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