Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Topics Arrays Description Enhance the last assignment so that it will have separate functions for computing min, max, mean, and median. Otherwise, it will work

Topics

Arrays

Description

Enhance the last assignment so that it will have separate functions for computing min, max, mean, and median. Otherwise, it will work the same way as the last assignment. The enhanced assignment will have the following additional functions.

A function computeMin for computing min

A function computeMax for computing max

A function computeMean for computing mean (or average)

A function computeMedian for computing median (optional)

Testing:

For turning in the assignment, perform the test run below with the data shown

Input Test Run

(User input is shown below in bold).

Enter data values count

12

Enter a data value

7.2

Enter a data value

7.6

Enter a data value

5.1

Enter a data value

4.2

Enter a data value

2.8

Enter a data value

0.9

Enter a data value

0.8

Enter a data value

0.0

Enter a data value

0.4

Enter a data value

1.6

Enter a data value

3.2

Enter a data value

6.4

Output Test Run

Original Data:

7.2 7.6 5.1 4.2 2.8 0.9 0.8 0.0 0.4 1.6 3.2 6.4

Sorted Data:

0.0 0.4 0.8 0.9 1.6 2.8 3.2 4.2 5.1 6.4 7.2 7.6

Min Value: 0.0

Max Value: 7.6

Mean: 3.35

Median: 3.0

Implementation

main function

The function main should provide the following:

Prompt the user for total number of items in the data.

Input the data items from the user and store them in array named data.

Copy the data from array data to another array named sdata.

Sort the array sdata.

Call the function computeMin for finding min and pass it the sorted array sdata and the length of the filled part.

Call the function computeMax for finding max and pass it the sorted array sdata and the length of the filled part.

Call the function computeMean for finding mean (average) and pass it the sorted array sdata and the length of the filled part..

Call the function computeMedian for finding median and pass it the sorted array sdata and the length of the filled part.

Display the original data, sorted data and min, max, mean and median values of the data.

computeMin function

The function computeMin will receive a sorted double array and the length of its filled part as parameters and will return its min value as a double. The min value refers to the smallest value in the data. Below is the header for this function with empty body.

double computeMin ( double sdata [ ], int length )

{

}

computeMax function

The function computeMax will receive a sorted double array and the length of its filled part as parameters and will return its max value as a double. The max value refers to the largest value in the data. Below is the header for this function with empty body.

double computeMax ( double sdata [ ], int length )

{

}

computeMean function

The function computeMean will receive a sorted double array and the length of its filled part as parameters and will return its mean as a double. The mean refers to the average of all the items in the data. Below is the header for the function with empty body

double computeMean ( double sdata [ ], int length )

{

}

computeMedian function

The function computeMedian will receive a sorted double array and length of its filled part as parameters and will return its median as a double. The median refers to value of that item in the data which has as many data items smaller than it as there are larger than it. Essentially it is the middle or central item in the data. If there are two such items (such as in an even size data), then median is the average of those two items. Below is the header for the function with empty body

double computeMedian ( double sdata [ ], int length)

{

}

main function

//main function

int main ( )

{

int length;

double data[20];

double sdata[20];

cout << "Enter data values count <1-20>" << endl;

cin >> length;

//call input function to input the array

input (data, length);

//call copy function to copy data array into sdata array

//call sort function to sort sdata array

//call computeMin function to find min value

double min=computeMin(sdata, length);

//call computeMax function to find min value

double max= computeMax(sdata, length);

//call computeMean function to find mean value

//call computeMedian function to find median value

cout << "Original data: " << endl;

//call display function to display data array

cout << "Sorted data: " << endl;

//call display function to display sdata array

//display min value

//display max value

//display mean value

//display median value

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Database Systems Design Implementation And Project Management

Authors: Albert K.W. Yeung, G. Brent Hall

1st Edition

1402053932, 978-1402053931

More Books

Students also viewed these Databases questions

Question

What are the stages of project management? Write it in items.

Answered: 1 week ago

Question

why do consumers often fail to seek out higher yields on deposits ?

Answered: 1 week ago