Question: Program in C++, file being referenced is a simple data file with random amounts like 10.75, 8, 0.25, etc. Program first opens input and output

Program in C++, file being referenced is a simple data file with random amounts like 10.75, 8, 0.25, etc.

Program first opens input and output files and checks that they opened OK. It then reads how many purchases will be input from the file and dynamically allocates an array of that many elements to hold these purchases. Program then loads the specified number of purchases from the file into the array. It sorts the array, finds the average and the median price of all purchases and displays all data on the terminal screen and writes it to an output file.

The Boolean functions return true if files successfully open, else false//main then tests Boolean values and returns to Op. Sys. if false//I allowed user to enter file names inside these

bool openInputFile(ifstream &fin);

bool openOutputFile(ofstream &fout);

void inputPurchases(ifstream &fin, float *arrayPtr, int howMany);

void outputPurchasesAndInfo(float *arrayPtr, int howMany, float avg, float median);

void outputPurchasesAndInfo(ofstream &fout, float *arrayPtr, int howMany, float avg, float median);

float averagePurchase( float *arrayPtr, int howMany);

void BubbleSort(float *numbersPtr, int numbersSize);

float medianPurchase(float *arrayPtr, int howMany);

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!