Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ ONLY. Develop a program that calculates basic statistics on a one-dimensional array of doubles. Your program should first prompt the user for the size

C++ ONLY.

Develop a program that calculates basic statistics on a one-dimensional array of doubles. Your program should first prompt the user for the size of the array followed by prompting for individual elements of the array. Your program should contain the following functions:

min()

Finds and returns the minimum value within the array.

max()

Finds and returns the maximum value within the array.

mean()

Finds and returns the mean value of the elements in the array.

median()

Finds and returns the median value of the elements in the array.

sort()*

Sorts the elements of the array in ascending order.

readArray()

Populates the elements of the array with input from the user (or via file redirection).

printArray()

Prints the elements of the array.

*You may use any sorting algorithm that you want. Here are a few easy suggestions:

Bubble sort pseudocode:

do swapped = false for each i in 1 to length(A) inclusive do: if A[i-1] > A[i] then swap A[i-1] and A[i] swapped = true end if end for while swapped

Insertion sort pseudocode:

i 1 while i 0 and A[j-1] > A[j] swap A[j] and A[j-1] j j - 1 end while i i + 1 end while

Additional Specifications:

Your program should not use any pre-existing classes such as string or vector classes!

Your program should consist of a header that contains the following information:

Firstname and lastname of the programmer.

Date and time of the program completion.

A brief description of the program function.

Input requirements and format.

Output of the program.

Any additional needed comments (e.g. related to compilation, execution or other requirements).

Any information related to the licensing agreement.

Each function needs to be properly commented.

Your comments needs to include a description of the function.

Description of the inputs.

Description of the output.

Any additional notes assisting future programmers to comprehend the complex portions of your functions.

Make sure your program compiles and runs on one of the Linux machines in the Linux lab before you submit.

Your program should consist of a single source code.

Submit the source code (.cpp) not the executable.

NAME YOUR FILE: Assignment2_.cpp (replace with your own last name.)

Example Outputs:

image text in transcribed

Examples using file redirection:

image text in transcribed

image text in transcribed

casey@vanderwaal:-/Dropbox/Teaching/CSCE24oFalt2617/Projects/Assignment2$ g++ Assignment2.cpp casey@vanderwaal:-/Dropbox/Teaching/CSCE240Fall2017/Projects/Assignment2$ ./a.out Please enter the size of your array: 6 Please enter 6 elements to populate the array. 212.3-6799 The elements of the array are: 212.3-6 7 99 The elements of the array sorted in ascending order: 6 0 27 12.3 99 The min of the array is-6 The max of the array is 99 The mean of the array is 19.05 The median of the array is 4.5 casey@vanderwaal:-/Dropbox/Teaching/CSCE240Fall2017/Projects/Assignment2$

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

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions

Question

How to find if any no. is divisble by 4 or not ?

Answered: 1 week ago

Question

Explain the Pascals Law ?

Answered: 1 week ago

Question

What are the objectives of performance appraisal ?

Answered: 1 week ago