Details of this Paper

class ArraySum

Description

solution


Question

ArraySum;Write a program which reads an integer n and then reads an n x n array of integers and outputs the sum of all the elements of the array. Name your class ArraySum. Use prompts and output labels as in the following examples;rows: 1;row 0: 1;total: 1;rows: 2;row 0: 1 2;row 1: 3 4;total: 10;rows: 5;row 0: 1 1 1 1 1;row 1: 1 1 1 1 1;row 2: 1 1 1 1 1;row 3: 1 1 1 1 1;row 4: 0 0 0 0 -1;total: 19;----------------------------------;2- MagicSquare;An n x n array that is filled with the numbers 1, 2, 3,..., n * n with no repeating numbers is a magic square if the sum of the elements in each row (there are n rows), in each column (there are n columns), and in each diagonal (there are 2 diagonals) is the same value.;Write a program which reads 16 integers and outputs one of "magic square" or "not a magic square" when those 16 integers are put into a 4 x 4 array in row major order starting with row index 0. Name your class MagicSquare. Use the prompt "numbers: " and output as in the following examples;numbers: 16 3 2 13 5 10 11 8 9 6 7 12 4 15 14 1;magic square;numbers: 1 14 15 4 12 7 6 9 8 11 10 5 13 2 3 16;magic square;numbers: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 17;not a magic square;numbers: 16 3 2 13 5 10 11 8 9 6 7 12 4 15 1 14;not a magic square;numbers: 5 10 11 8 9 6 7 12 4 15 14 1 16 3 2 13;not a magic square;numbers: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1;not a magic square

 

Paper#68988 | Written in 18-Jul-2015

Price : $27
SiteLock