Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Magic squares are 2-D arrays NxN containing every integer 1, 2...N*2 where every row, column, and diagonal sums to the same value See http://mathworld.wolfram.com/MagicSquare.html

Java

image text in transcribed

Magic squares are 2-D arrays NxN containing every integer 1, 2...N*2 where every row, column, and diagonal sums to the same value See http://mathworld.wolfram.com/MagicSquare.html for a lot of detailed explanation and information on construction You are going to write a program that allows a user to input a couple parameters and print a magic square appropriate for those parameters. Program Description Your program should ask the user to enter a number of sides (N) for the magic square. Your program should handle: 1, 3, 4, 5, 7, 8, 9, 11, 12,13, 15, 16, 17 For 2, you should print "Not possible" For 6, 10, 14, you should print "Don't press your luck" For all other values, you should produce a valid Magic Square Your program should also ask the user for a preferred printing format, with or without box outlines For a 3x3, without outlines looks like: 9 1 6 3 5 7 4 9 2 with outlines looks like: 31517 141912 Finally, for any allowed N > 2 your program should ask for an "example id" a-d. Every time a user enters 'a' for a particular N, they should see the same square; likewise for b-c. However, the square they see when they enter 'a' should not be identical to the one they see for'b', 'c' or 'd'; likewise for 'b' and 'c', 'c' and 'd', and 'b' and 'd'. (in other words, they're all different) After requesting these 3 options, your program should print an appropriate magic square Unit Tests You must submit JUnit tests that verify all of the major components of your solution. You should have no fewer than 3 and probably no more than 10

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Informix Database Administrators Survival Guide

Authors: Joe Lumbley

1st Edition

0131243144, 978-0131243149

More Books

Students also viewed these Databases questions

Question

Find the derivative of y= cos cos (x + 2x)

Answered: 1 week ago