Question: 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

This is the code I did for this activity. Everything works fine

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 positive

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!