subject

Write a program that uses a 3 3 3 array and randomly place each integer from 1 to 9 into the nine squares. the program calculates the magic number by adding all the numbers in the array and then divid- ing the sum by 3. the 3 3 3 array is a magic square if the sum of each row, each column, and each diagonal is equal to the magic number. your program must contain at least the following functions: a function to randomly fill the array with the numbers and a function to deter- mine if the array is a magic square. run these functions for some large number of times, say 1,000, 10,000, or 1,000,000, and see the number of times the array is a magic square.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 00:30
Which of the following would you find on a network
Answers: 3
question
Computers and Technology, 23.06.2019 19:00
This question involves a class named textfile that represents a text file. public class textfile { private string filename; private string filename; private arraylist words; // constructors not shown // postcondition: returns the number of bytes in this file public int filesize() { } // precondition: 0 < = index < words.size() // postcondition: removes numwords words from the words arraylist beginning at // index. public void deletewords(int index, int numwords) { } // precondition: 0 < = index < = words.size() // postcondition: adds elements from newwords array to words arraylist beginning // at index. pub lic voidaddwords(int index, string[] newwords) { } // other methods not shown } complete the filesize() method. the filesize() is computed in bytes. in a text file, each character in each word counts as one byte. in addition, there is a space in between each word in the words arraylist, and each of those spaces also counts as one byte. for example, suppose the words arraylist stores the following words: { mary had a little lamb; its fleece was white as snow. } the filesize() method would compute 4 + 3 + 1 + 6 + 5 + 4 + 6 + 3 + 5 + 2 + 5 as the sum of the lengths of each string in the arraylist. the value returned would be this sum plus 10, because there would also be 10 spaces in between the 11 words. complete the filesize() method below: // postcondition: returns the number of bytes in this file public int filesize() { }
Answers: 1
question
Computers and Technology, 24.06.2019 02:30
Assume a class window with accessor method getwidth that accepts no parameters and returns an integer. assume further an array of 3 window elements named winarr, has been declared and initialized. write a sequence of statements that prints out the width of the widest window in the array.
Answers: 2
question
Computers and Technology, 24.06.2019 13:30
Consider jasper’s balance sheet. which shows how to calculate jasper’s net worth?
Answers: 1
You know the right answer?
Write a program that uses a 3 3 3 array and randomly place each integer from 1 to 9 into the nine sq...
Questions
question
Mathematics, 20.11.2020 20:40
question
Mathematics, 20.11.2020 20:40
question
Mathematics, 20.11.2020 20:40
question
Mathematics, 20.11.2020 20:40
question
Advanced Placement (AP), 20.11.2020 20:40
question
Mathematics, 20.11.2020 20:40
Questions on the website: 13722360