Question
I need this program in C++. Define statistical functions that sort an array, find the minimum and maximum number in the array, calculate the range,
I need this program in C++.
Define statistical functions that sort an array, find the minimum and maximum number in the array, calculate the range, mean, and median of the numbers in the array. Write a main program that displays a menu to do these:
- Insert - to input 20 numbers into a one-dimensional array,
- Sort - call functions sort that has been defined earlier and display the result
- Mean - call functions mean that have been defined earlier and display the result
- Median - call function median that has been defined earlier and displays the result
- Range - call function median that has been defined earlier and display the result
- Exit - will stop the program from running, otherwise, the program will continue running by asking the user to input a choice from the menu.
Formula
The Mean is the average of a set of numbers.
The "Mean" is computed by adding all of the numbers in the data together and dividing by the number of elements contained in the data set.
Example: Data Set = 2, 5, 9, 7, 5, 4, 3 Number of Elements in Data Set = 7 Mean = ( 2 + 5 + 9 + 7 + 5 + 4 + 3 ) / 7 = 5
The Median is the middle value of a set of ordered numbers. First, reorder the data set from the smallest to the largest. If the number of elements is odd, then the Median is the element in the middle of the data set. If the number of elements is even, then the Median is the average of the two middle terms.
Example: Odd Number of Elements
Data Set = 2, 5, 9, 7, 5, 4, 3
Reordered = 2, 3, 4, 5, 5, 7, 9 - the middle term is 5 Median = 5
Example: Even Number of Elements
Data Set = 2, 5, 9, 3, 5, 4
Reordered = 2, 3, 4, 5, 5, 9 - the middle terms are 4 and 5
Median = ( 4 + 5 ) / 2 = 4.5 - the median is the average of the two middle terms
The "Range" is the difference between the largest value and smallest value in a set of data.
First, reorder the data set from smallest to largest then subtract the first element from the last element.
Example:
Data Set = 2, 5, 9, 7, 5, 4, 3 Reordered = 2, 3, 4, 5, 5, 7, 9 Range = ( 9 - 2 ) = 7
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started