Write a program that will compute a number of statistics for a set of data provided by the user. The data will be made up of decimal numbers. After inputting the data, the program will compute and display the following statistics relating to the data.
Min Value
Max Value
Mean Value
Median Value
Implementation
Do the above assignment by creating two classes: Statistics and TestStatistics.
The class Statistics will be used as a blue print for a Statistics object.
It will keep a set of data and will provide methods for computing statistics relating to the data. The data will be provided to the Statistics object in an array during object construction.
The class TestStatistics will be used to hold the method main. The method main will be used to input the data, create the Statistics object, compute statistics by calling Statistics object methods and display the values received.
Class Statistics
The class Statistics will provide the following:
A private array variable data for holding user data.
A private array variable sdata for holding a sorted copy of the above data.
A constructor to initialize the array data.
A method getOrigData for returning a copy of the array data.
A method getSortedData for returning a copy of the original array but now sorted.
A method findMin for computing min
A method findMax for computing max
A method findMean for computing mean (or average)
A method findMedian for computing median
Class TestStatistics
The class TestStatistics will provide the method main which will do the following:
Prompt the user for the number of total items in the data.
Create an array of that size.
Input data items from the user and store them in the array.
Create an object of the class Statistics and pass it the data array.
Call a Statistics object method to obtain the original data array.
Call a Statistics object method to obtain the data array but now sorted in ascending order.
Call Statistics object methods for calculating the min, max, mean and median values.
Display the original data, data sorted in ascending order, min, max, mean and median values.
Testing
Test Run:
Input
(User input is shown in bold).
Enter the Number Of Data Values: 12 Enter Data Value: 7.2 Enter Data Value: 7.6 Enter Data Value: 5.1 Enter Data Value: 4.2 Enter Data Value: 2.8 Enter Data Value: 0.9 Enter Data Value: 0.8 Enter Data Value: 0.0 Enter Data Value: 0.4 Enter Data Value: 1.6 Enter Data Value: 3.2 Enter Data Value: 6.4
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference
and should not be submitted as is. We are not held liable for any misuse of the solutions.
Please see the frequently asked questions page
for further questions and inquiries.
Kindly complete the form.
Please provide a valid email address and we will get back to you within 24 hours.
Payment is through PayPal, Buy me a Coffee
or Cryptocurrency.
We are a nonprofit organization however we need funds to keep this organization operating
and to be able to complete our research and development projects.