Create a java class called ArrayOperations. Add the static methods described below. Then write a test class to verify that all of your methods work. Static Methods for ArrayOperations The lcass name is ArrayOperations It has one static method called findSum. This method returns the sum of the elements in an array To invoke this method from another class, we use the class name (ArrayOperations.findSum(MyArray)); toString : This method signature should be: public static String toString(int[] anArray). It should return a String that consists of all elements in the array. For example if the input array consists of {1, 5, 9, 2}, then toString should return the string 1 5 9 2 findMaxMin : The signature for this method should be public static int[] findMaxMin(int[] anArray) Notice that the method returns an array of int – not a single value. In this method Write code to declare an array of int with two elements – say limits Find the largest element in the array and store it in limits[0] Find the smallest element in the array and store it in limits[1] return limits findAverage: The signature for this method should be public static double findAverage(int[] myArray) In the implementation, we simply need to compute the sum of the array elements and divide them by the length of the array. We can do this by using findSum and dividing by the array length. The test program ArrayOperationsTest The test class should conform to the following specifications: The name of the class is ArrayOperationsTest The test class should contain a static method called makeArray The test class should contain a static method called menu that offers the user the following choices Make a new array (ask the user for the number of elements) Calculate and print the sum of the array elements Find and print max and min values in the array Print the toString for the array Calculate and print the average value in the array QUIT The program should have a main method that works as follows Display the menu and get user choice Call the appropriate method(s) to do what the user needs and display the results Loop until the user selects QUIT Summary ArrayOperations has static methods findSum, findAverage, findVariance, and findMaxMin. ArrayOperationsTest has methods makeArray, menu, and main. You will need to import Scanner and Random.   A sample run might consist of Creating an array with 10 elements Printing the sum of the array elements Printing the max and min values in the array Printing the average value for the array Printing the variance for the array Printing the toString for the array

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Create a java class called ArrayOperations. Add the static methods described below. Then write a test class to verify that all of your methods work.

Static Methods for ArrayOperations

  1. The lcass name is ArrayOperations
  2. It has one static method called findSum. This method returns the sum of the elements in an array
  3. To invoke this method from another class, we use the class name (ArrayOperations.findSum(MyArray));
  4. toString : This method signature should be: public static String toString(int[] anArray). It should return a String that consists of all elements in the array. For example if the input array consists of {1, 5, 9, 2}, then toString should return the string 1 5 9 2
  5. findMaxMin : The signature for this method should be public static int[] findMaxMin(int[] anArray) Notice that the method returns an array of int – not a single value. In this method
  6. Write code to declare an array of int with two elements – say limits
  7. Find the largest element in the array and store it in limits[0]
  8. Find the smallest element in the array and store it in limits[1]
  9. return limits
  10. findAverage: The signature for this method should be public static double findAverage(int[] myArray)

In the implementation, we simply need to compute the sum of the array elements and divide them by the length of the array. We can do this by using findSum and dividing by the array length.

The test program ArrayOperationsTest

The test class should conform to the following specifications:

  1. The name of the class is ArrayOperationsTest
  2. The test class should contain a static method called makeArray
  3. The test class should contain a static method called menu that offers the user the following choices
  4. Make a new array (ask the user for the number of elements)
  5. Calculate and print the sum of the array elements
  6. Find and print max and min values in the array
  7. Print the toString for the array
  8. Calculate and print the average value in the array
  9. QUIT
  10. The program should have a main method that works as follows
  11. Display the menu and get user choice
  12. Call the appropriate method(s) to do what the user needs and display the results
  13. Loop until the user selects
  14. QUIT

Summary

ArrayOperations has static methods findSum, findAverage, findVariance, and findMaxMin.

ArrayOperationsTest has methods makeArray, menu, and main. You will need to import Scanner and Random.

 

A sample run might consist of

  1. Creating an array with 10 elements
  2. Printing the sum of the array elements
  3. Printing the max and min values in the array
  4. Printing the average value for the array
  5. Printing the variance for the array
  6. Printing the toString for the array
AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
steps

Unlock instant AI solutions

Tap the button
to generate a solution

Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education