(Solved) : Creating Interactive Program User Interact Mp7 Player User Loads Songs Beginning Program P Q37707269 . . .
You are creating an interactive program for a user to interactwith their MP7 player.
The user loads songs at the beginning of the program, andpopulates an array of
Song structures. Each song has 5 members: artist (string),title(string), duration or
length (int), genre (string), and times played (int). The usercan play songs, edit
their information, store their information in a file, anddisplay all the songs in the
MP7 player. The user can also quit the program.
Step-by-Step Instructions:
Create an array of structs of type Song, which will have 5members:
– Artist (String)
– Title (String)
– Length in seconds (int)
– Genre (String)
– Times Played (int)
Look in Chapter 11 (book or notes) for examples of structs.
Then you must implement the following functionality (select froma menu), with one
option corresponding to a function.
1. Edit: this function must allow the user to find a song in thelist by entry subscript
number (in the array starting at 0). The user is asked in asubmenu which attribute
(artist, title, length, genre, times played) that will beedited. This is in a loop to
change a single attribute each time. If the user selects -1,then the program quits
the loop and exits the function.
2. Play: this function must allow the user to find a song bysubscript number in the
array. It will then print out the attributes of the song andevery song after that one
until the end of the list. The user can also select -1 and playall the songs in order.
This function calls the function display for part of its body.For each song that is
played, update the xPlayed member for it.
3. Display: this function must allow the user to print out theinformation for a single
song entry in the player (by number).
4. Store: this function writes the content to an output file ofyour choice, but you
must append “.txt” to the name for it. (you type file it meansfile.txt).
5. Turn off (Quit): Quits the program by powering down (notliterally J)1.
The following code is provided for the menus and the reading inof the
file. For the functions, please follow the prototypesexactly.
void readData(Song[],int,string);
void showMenu();
void showEditMenu();
void displaySong(Song[],int);
void playSongs(Song[],int);
void editSongs(Song[],int);
void storeSongs(Song[],int);
void showMenu(){
cout << endl;
cout << “Main Menu” << endl;
cout << “1. Store Songs” << endl;
cout << “2. Display Songs” << endl;
cout << “3. Play Songs” << endl;
cout << “4. Edit Songs” << endl;
cout << “5. Quit (Save and shut off)” << endl;
cout << “Please select 1 through 5” << endl;
}
void showEditMenu(){
cout << endl;
cout << “Edit Submenu” << endl;
cout << “Please select the song field you would liketo
edit” << endl;
cout << “1. Artist” << endl;
cout << “2. Title” << endl;
cout << “3. Duration” << endl;
cout << “4. Genre” << endl;
cout << “5. Times Played” << endl;
cout << “Please select 1 through 5” << endl;
cout << “Type -1 to quit this menu” << endl;
}
void readData(Song sg[],int N,string filename){
int i=0;
ifstream ifd;
ifd.open(filename.c_str());
while(i < N){
getline(ifd,sg[i].artist);
getline(ifd,sg[i].title);
getline(ifd,sg[i].genre);
ifd >> sg[i].len;
ifd >> sg[i].xPlayed;
ifd.ignore();
i++;
}
ifd.close();
}
Input File Data:
Taylor Swift
Shake it Off
Pop
12
3
Drake
Own It
Rap
3
3
Drake
The Motto
Rap
7
4
Christina Perri
Trust
Pop
3
5
Justin Bieber
No Sense
Pop
6
1
Eminem
Vegas
Rap
8
3
Adele
Remedy
Pop
24
4
Taylor Swift
Stay Stay Stay
Pop
5
1
Garth Brooks
The Old Stuff
Country
11
2
Extra Credit (+6 total)
1. Add/delete song from list (vectors needed). (+2 each, +4total)
2. Enumeration (enum) of genre types instead of strings(+1).
3. Search by artist or title instead of by subscript fordisplay, edit,
play (+1).
Expert Answer
Answer to Creating Interactive Program User Interact Mp7 Player User Loads Songs Beginning Program P Q37707269 . . .
OR