Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need a C++ program that calculates statistics on a set of test scores. The sco

ID: 3662652 • Letter: I

Question

I need a C++ program that calculates statistics on a set of test scores.

The scores should be stored in a dynamically allocated array.

The program should have:

- Open a file that has a set of test scores. The first value is the number of scores in the file.

-Allocate an array to hold the scores. Only dynamic allocation will be accepted.

- Should read the test scores into the array. Have a separate function to read the scores.

- should Sort the scores in ascending order using qsort()

-Print the sorted scores. Have a separate function to print the scores.

-Calculate and print the average and the median and mode of the scores. Have separate functions to calculate average, median and mode. Suggestion: build a frequency array to aid in the mode calculation.

Explanation / Answer

Please find the required solution:

#include <iostream>
#include <fstream>

using namespace std;

int main()
{
//declare dynamic array
int * foo;
  
//declare temporary variables
int i=0,num;
  
//point to file
fstream myfile("scores.txt", std::ios_base::in);
  
// while file has data read integer from file and store in array
while (myfile >> num)
{
if(i==0)
{
foo = new int [num];//first number is size
cout<<"Number of scores:"<<num<<endl;
cout<<"List of scores in file:"<<endl;
i++;
}
else
{
foo[i-1]=num;//store scores to array
cout<<foo[i-1]<<endl;
}
}
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote