Question: May someone help me finish a program that reads a (.dat) file and outputs the data three times. 1st time being everything in the file

May someone help me finish a program that reads a (.dat) file and outputs the data three times.

1st time being everything in the file no order just as is

2nd time is same as first but includes gross revenue and proft.

3rd times arranges data based on sales from highest to lowest

Template of code is down below using parallel arrays to output and calculate data cant change that

#include #include #include using namespace std;

////// prototypes int readDatafile(string[], string[], int[], float[], string[], int); void outputData(string[], string[], int[], float[], string[], int); void calcTotals(/* ... */); void outputResults(/* ... */);

/////// add prototypes and functions as needed for sorting

main() { static int ARRAYSIZE= 10; string names[ARRAYSIZE]; // song names string artists[ARRAYSIZE]; // artist names int year[ARRAYSIZE]; // year of release float sales[ARRAYSIZE]; // sales string medium[ARRAYSIZE]; // medium ID float gross[ARRAYSIZE]; // gross revenue float profit[ARRAYSIZE]; // profit

}

/////// open and read the datafile int readDatafile(string artist[], string name[], int year[], float sales[], string medium[], int max) { string fname; ifstream ifs; cout<< "Enter file name: "; cin>> fname; ifs.open(fname.c_str()); if(ifs.fail()){ cout<< "Error opening file: " << fname << endl; return 1; }

int num=0;

}

///// output the data! void outputData(string artist[], string name[], int year[], float sales[], string medium[], int max) { cout << endl; cout << "Song Sales data:" << endl; cout << "----------------" << endl; }

.Dat file has information based on Artist Song_Title Year Sales Medium

The program will use this information to compute the gross revenue and the profit generated by each song using the following information. The cost to produce a song on physical media is taken to be 75 cents while the cost for a digitally released song is 25 cents. The sale prices are $1.50 for the physical media and 99 cents for downloads. (Use variables to set fixed values.) The final step will be to output a neatly formatted list of the song information, including revenue, and profit, sorted by the profit from highest to lowest.

Bing_Crosby White_Christmas 1942 50 physical Elton_John Candle_in_the_Wind 1997 33 physical Mungo_Jerry In_the_Summertime 1970 30 physical Bing_Crosby Silent_Night 1935 30 physical Bill_Haley Rock_Around_the_Clock 1954 25 physical Ed_Sheeran Shape_of_You 2017 41.5 digital Luis_Fonsi Despacito 2017 36.1 digital Kesha TiK_ToK 2009 25.2 digital Ed_Sheeran Perfect 2017 21.4 digital

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!