Question: IN C++ Write a program that reads a text file containing a number of test scores into an array and calculates the average and median

IN C++ Write a program that reads a text file containing a number of test scores into an array and calculates the average and median of the scores. Define a constant to hold the array size and use it to declare the array that holds the scores.

const int MAX_SCORES = 40;

You will need to implement the following functions:

int getScores (int scores[], int array_size);

This function should open the file lab6.txt and read the scores into an array. The function will return the number of scores successfully read from the file. If the file does not open successfully the function should return zero, meaning there are not scores in the array. This needs to be tested in main before you proceed to calculating mean and median.

double calcAverage (int scores[], int num_scores);

This function should calculate and return the average of the scores passed in parameter score.

double calcMedian (int scores[], int num_scores);

This function should return the median value in the array. To determine the median, the array must be sorted first. Note that if the array has an odd number of scores, the median is the one in the middle, but if the array has an even number of scores, there are two in the middle and they need to be averaged to produce the median.

Implement the SelectionSort function taught in class.

Your program should print on the screen: the sorted array, the average and the median.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!