Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Trying to learn Array of Structure Overview: The supplied data file2, songs.dat and songs2.dat contains a listing of the bestselling song recordings, released as singles,

Trying to learn Array of Structure

Overview: The supplied data file2, songs.dat and songs2.dat contains a listing of the bestselling song recordings, released as singles, of all time. The assignment is to complete a program that will first read the song information, which includes song sales, and compute revenue and profit using additional information provided below. Each line of the data file will contain the artists name, the song name, the year released, the total sales (in millions) and medium that the song was released on. The medium will either be physical, which includes records and CDs or digital, i.e. downloads. The file format is as follows: Artist Song_Title Year Sales Medium To simplify file parsing, multiple words in an artist name and/or song title are combined into one string with an underbar character separating each word. The programs 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.

#include #include #include using namespace std;

// struct definition for a child object struct song { string name; // song names string artist; // artist names int year; // year of release float sales; // sales string medium; // medium ID float gross; // gross revenue float profit; // profit };

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

// additional prototypes for sorting

main() { static int ARRAYSIZE= 10; song slist[ARRAYSIZE];

}

// open and read the datafile int readDatafile(song list[], int max) { string fname; ifstream ifs; int num=0;

}

// output the data! void outputData(song list[], int max) { cout << endl; cout << "Song Sales data:" << endl; cout << "----------------" << endl; }

Trying to use this template to read a .dat file and ask user to open name of said file to output

data three times.

1st output is everything in the file

2nd output is the same as first but includes gross revenue and profit

3rd output is arranged highest to lowest based enitrely on sales

inside the .dat file is this

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

arranged to be like this: Artist Song_Title Year Sales Medium

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

Students also viewed these Databases questions

Question

What are the different goal types of economic entities?

Answered: 1 week ago