Do the Random2DArray And the tester is at the bottom import java.util.Random; /** * Store a 2-D array and provide methods to * get the average values of any row, any * column, or the entire array. * * Step 1: Enter your name for @author and today's date for @version * @author * @version */ public class Random2DArray { public final int LOW_LIMIT = -10; public final int HIGH_LIMIT = 10; // Step 2: Declare an instance variable of a 2-D // array of int // Step 3: Complete the constructor /** * Constructs an object of class Random2DArray * by initializing the instance variable to * the passed in parameter. * * @param array a 2-D array of int */ public Random2DArray(int[][] array) { } // Step 4: Complete the constructor /** * Constructs an object of class Random2DArray. * It creates a 2-D array of int with the * specified rows and columns for the instance * variable, then creates a Random object with * the specified seed and use it to fill the * entire array with random numbers in the * range of [LOW_LIMIT, HIGH_LIMIT]. * * @param rows number of rows of the 2-D array * @param cols number of columns of the 2-D array * @param seed the seed of the Random generator */ public Random2DArray(int rows, int cols, int seed) { } // Step 5: Complete method rowAverage() /** * Gets the average value of the specified row. * * You should use the enhanced for loop. * * @param rowIndex the index of the specified row * @return the double average of the specified row */ public double rowAverage(int rowIndex) { } // Step 6: Complete method colAverage() /** * Gets the average value of the specified column. * * @param colIndex the index of the specified column * @return the double average of the specified column */ public double colAverage(int colIndex) { } // Step 7: Complete method arrayAverage() /** * Gets the average value of the entire array. * * @return the double average of the entire array */ public double arrayAverage() { } } TESTER public class Random2DArrayTester { public static void main(String[] args) { int[][] array123 = { {1, 2, 3, 4, 5, 6, 7}, {2, 3, 4, 5, 6, 7, 8}, {3, 4, 5, 6, 7, 8, 9} }; Random2DArray arrayOne = new Random2DArray(array123); Random2DArray arrayTwo = new Random2DArray(5, 11, 123); Random2DArray arrayThree = new Random2DArray(11, 5, -123); int rowIndex = 0; double average = arrayOne.rowAverage(rowIndex); System.out.printf("The row average: %.2f.%n", average); System.out.println("Expected: 4.00."); average = arrayTwo.rowAverage(rowIndex); System.out.printf("The row average: %.2f.%n", average); System.out.println("Expected: -0.36."); average = arrayThree.rowAverage(rowIndex); System.out.printf("The row average: %.2f.%n", average); System.out.println("Expected: -7.40."); int colIndex = 2; average = arrayOne.colAverage(colIndex); System.out.printf("The column average: %.2f.%n", average); System.out.println("Expected: 4.00."); average = arrayTwo.colAverage(colIndex); System.out.printf("The column average: %.2f.%n", average); System.out.println("Expected: 1.00."); average = arrayThree.colAverage(colIndex); System.out.printf("The column average: %.2f.%n", average); System.out.println("Expected: -2.00."); average = arrayOne.arrayAverage(); System.out.printf("The average of the 2-D array: %.2f.%n", average); System.out.println("Expected: 5.00."); average = arrayTwo.arrayAverage(); System.out.printf("The average of the 2-D array: %.2f.%n", average); System.out.println("Expected: -1.31."); average = arrayThree.arrayAverage(); System.out.printf("The average of the 2-D array: %.2f.%n", average); System.out.println("Expected: -0.27."); } }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Do the Random2DArray And the tester is at the bottom import java.util.Random; /** * Store a 2-D array and provide methods to * get the average values of any row, any * column, or the entire array. * * Step 1: Enter your name for @author and today's date for @version * @author * @version */ public class Random2DArray { public final int LOW_LIMIT = -10; public final int HIGH_LIMIT = 10; // Step 2: Declare an instance variable of a 2-D // array of int // Step 3: Complete the constructor /** * Constructs an object of class Random2DArray * by initializing the instance variable to * the passed in parameter. * * @param array a 2-D array of int */ public Random2DArray(int[][] array) { } // Step 4: Complete the constructor /** * Constructs an object of class Random2DArray. * It creates a 2-D array of int with the * specified rows and columns for the instance * variable, then creates a Random object with * the specified seed and use it to fill the * entire array with random numbers in the * range of [LOW_LIMIT, HIGH_LIMIT]. * * @param rows number of rows of the 2-D array * @param cols number of columns of the 2-D array * @param seed the seed of the Random generator */ public Random2DArray(int rows, int cols, int seed) { } // Step 5: Complete method rowAverage() /** * Gets the average value of the specified row. * * You should use the enhanced for loop. * * @param rowIndex the index of the specified row * @return the double average of the specified row */ public double rowAverage(int rowIndex) { } // Step 6: Complete method colAverage() /** * Gets the average value of the specified column. * * @param colIndex the index of the specified column * @return the double average of the specified column */ public double colAverage(int colIndex) { } // Step 7: Complete method arrayAverage() /** * Gets the average value of the entire array. * * @return the double average of the entire array */ public double arrayAverage() { } } TESTER public class Random2DArrayTester { public static void main(String[] args) { int[][] array123 = { {1, 2, 3, 4, 5, 6, 7}, {2, 3, 4, 5, 6, 7, 8}, {3, 4, 5, 6, 7, 8, 9} }; Random2DArray arrayOne = new Random2DArray(array123); Random2DArray arrayTwo = new Random2DArray(5, 11, 123); Random2DArray arrayThree = new Random2DArray(11, 5, -123); int rowIndex = 0; double average = arrayOne.rowAverage(rowIndex); System.out.printf("The row average: %.2f.%n", average); System.out.println("Expected: 4.00."); average = arrayTwo.rowAverage(rowIndex); System.out.printf("The row average: %.2f.%n", average); System.out.println("Expected: -0.36."); average = arrayThree.rowAverage(rowIndex); System.out.printf("The row average: %.2f.%n", average); System.out.println("Expected: -7.40."); int colIndex = 2; average = arrayOne.colAverage(colIndex); System.out.printf("The column average: %.2f.%n", average); System.out.println("Expected: 4.00."); average = arrayTwo.colAverage(colIndex); System.out.printf("The column average: %.2f.%n", average); System.out.println("Expected: 1.00."); average = arrayThree.colAverage(colIndex); System.out.printf("The column average: %.2f.%n", average); System.out.println("Expected: -2.00."); average = arrayOne.arrayAverage(); System.out.printf("The average of the 2-D array: %.2f.%n", average); System.out.println("Expected: 5.00."); average = arrayTwo.arrayAverage(); System.out.printf("The average of the 2-D array: %.2f.%n", average); System.out.println("Expected: -1.31."); average = arrayThree.arrayAverage(); System.out.printf("The average of the 2-D array: %.2f.%n", average); System.out.println("Expected: -0.27."); } }
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY