Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello! Learning c++ here. 1. Create a header file with template functions that calculate and return statistics on arrays of any numeric data type. 2.

Hello!

Learning c++ here.

1. Create a header file with template functions that calculate and return statistics on arrays of any numeric data type. 2. Test these functions by creating a program that allows the user to enter a series of doubles and then reports all of the statistics on those numbers. The header file should be named ArrayFunctions and have the following functions:

1. long double calcAverage(T* arr[], int size) 2. T findMax(T* arr[], int size) 3. T findMin(T* arr[], int size) 4. long double calcMedian(T* arr[], int size)

The array functions, except sort, should not change the order of the elements in the array argument. For the main program, make up a scenario that would require a series of double values: grades, expenses, temperatures, etc. User input should be bulletproofed and output should include a listing of the entered numbers in original order, the average, max, min, and median. Notes: 1. To calculate a median, sort the list and return the middle value. If the list size is an even number of elements, return the average of the two middle values. 2. C-style arrays must be sized with a constant or literal. For the median calculation you may need to copy the original array values into another array. You may make the second array an arbitrarily large size and work with it as a partial array.

I'm trying to figure out how to write them.

so far, this is a function I have come up with. Not sure if I got it correct.

template long double calcAverage(T* arr[], int size) { double total = 0; for (int i = 0; i < size; i++) total = total + *T; return total / size; }

Thank you for your help in advance. This language is in C++.

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

Data And Information Quality Dimensions, Principles And Techniques

Authors: Carlo Batini, Monica Scannapieco

1st Edition

3319241060, 9783319241067

More Books

Students also viewed these Databases questions

Question

Where and how are cash dividends reported?

Answered: 1 week ago