CSCI 1011 Java Programming Fall 2019 Summary Statistics Assignment
This is not a group project. Do your own work. Giving a solution to a student is as dishonest as getting a solution from anyone else. The objective of this assignment is for the student to gain experience with a user-defined data type, which includes work with an array, a class, a member variable, and member functions, including a constructor. Loops and if() statements are also needed. This assignment is worth 100 points, or 12.5% of your final grade. A solution which fails to compile will receive no more than half credit. Code which fails to run to a normal termination will receive no more than 2/3 credit. Write a class named Summary Statistics, which of course means that the file name must be SummaryStatistics.java.
Required elements:
1. A private member variable for an array of type long. This is a reference variable that I will call “v” in the rest of this assignment.
2. A constructor that accepts a reference to an array of type int. Copy the elements from the int array into a new long array (hereafter referred to as v). Store the long array reference in your private member variable from requirement #1.
3. A function named getAverage(), which accepts no arguments and returns a float value that is the average of the elements in the v array. Watch out for decimal truncation!
4. A function named getRange(), which accepts no arguments, which returns a long value, which is the range of the elements in v. Hint: The easy way to do this is to use two of the other functions.
5. A function named getMaximum(), which accepts no arguments and returns the value of the largest element in v. Pick the most appropriate return type.
6. A function named getMinimum(), which accepts no arguments and returns the value of the smallest element in the array. Pick the most appropriate return type.
7. A function named getMidrange(), which accepts no arguments, computes the midrange of the values in the array v, and returns that computed midrange. Pick the most appropriate return type.
8. A function named getValueAt(), which accepts an integer argument and returns the value at that index in the array. Pick the most appropriate return type.
9. A function named setValueAt(), which accepts an long argument and an int argument: the new value to store, and the index in the array at which to store the new value, in that order. Pick the most appropriate return type.
10. A function named getSum(), which accepts no arguments and returns the sum of the values in the
array. Pick the most appropriate return type.
Get Free Quote!
286 Experts Online