Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am really stuck and need help. Please! Array Practice Problems Write the following method. You will also need to create a main method that

I am really stuck and need help. Please! image text in transcribed
image text in transcribed
Array Practice Problems Write the following method. You will also need to create a main method that calls the methods and outputs the results. Write a method named createValues with one String parameter and 4 integer parameters: filename, numRows, numCols, maxValue, minValue. The method should create the input file filename that has the values numRows and numCols on the first row. After the first row, the file will have numRows rows with numCols columns of integer values. Each integer value should be generated using the Random class and should be in the from minValue to maxValue. 1. 2. For example: createValues( "values.txt", 10, 30, -50, 100); would create a file named values.txt with 10 and 30 on the first row. Following this first row would be 10 rows with 30 columns each containing random integer values between -50 and 100. Write a method named readValues with one String parameter named filename. The method should read the values in the file created by the method createValues into a 2D array and returns that 2D array as the method return value. Hint: The method should read in the first line of the input to get the dimensions of the 2D array. Then the method should instantiate the 2D array and read the rest of the file using nested for-loops. 3. Write a method computeRowAverages that has a 2D array of integers as the only formal parameter. The method should return a 1D array containing the average of the values in each row. For example, element 0 of the returned 1D array should have the average of row O in the 2D array. Element 1 of the returned array should have the average of row 1 of the 2D array. Etc. Write the following method: public static void shuffle( int [I values) The method should shuffle the values in the given array using the following algorithm 5. Go element 0 in the array. . Swap the value at that location with the value of a random element in the array. Repeat for the other n-1 elements in the array. In your main method, create a 1D array with the first 1000 integers. Then, call the shuffle method. Print out the values in the array before and after the shuffle operation using named printArrayt int [ values). printArray can also be used to output results for the other a method problems above

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

Marketing Database Analytics

Authors: Andrew D. Banasiewicz

1st Edition

0415657881, 978-0415657884

More Books

Students also viewed these Databases questions

Question

Why should units be carried along with numbers in a calculation?

Answered: 1 week ago