Question: C++ I need to add the ability to save data to a disk in one or more files in my program. The menu(s) should give
I need to add the ability to save data to a disk in one or more files in my program. The menu(s) should give the user the option to save or retrieve data.
//Please make sure the program runs in Microsoft Visual Studio
MY CODE:
#include
#include
using namespace std;
struct music
{
string title;
string artist;
string genre;
};
void menu(){
cout\"enter>
cout\"1.>
cout\"2.>
cout\"3.>
cout\"4.>
}
string manage_playlist(){
string pName;
cin.ignore();
cout
getline (cin, pName);
cin.clear();
return pName;
}
void manage_songs(music arr_str[],int i){
for(int k=0;k
{
cout
cin.ignore();
getline (cin, arr_str[i].title);
cout
cin.ignore();
getline (cin, arr_str[i].artist);
cout
cin.ignore();
getline (cin, arr_str[i].genre);
cout
cin >> arr_str[i].len;
}
}
void display(music arr_str[],string pName,float totalLength){
{
string sTitle1, sTitle2, sTitle3,pName;
string sArtist1, sArtist2, sArtist3;
string sGenre1, sGenre2, sGenre3;
float sLength1, sLength2, sLength3;
float playlistAverage;
cout
cout
cout
cout
cout
int choice = 0;
cout
cin>>choice
switch(choice)
{
case 1:
cout
break;
case 2:
cout
case 3:
cout
break;
case 4:
cout
break;
}
playlistAverage = totalLength / 3;
for(int k=0;k
{
cout
cout
cout
cout
cout
cout
}
cout
cout
}
}
int main()
{
music arr_str[10];
string pName;
float totalLength = 0.0;
int newChoice=0, i=0, k=0;
cout
cout
cout
while(1){
menu();
cin>>newChoice;
switch(newChoice) {
case 1:
pName = manage_playlist();
break;
case 2:
manage_songs(arr_str,i);
totalLength = totalLength + arr_str[i].len;
break;
case 3: display(arr_str,pName,totalLength);
break;
case 4: return 0;
}
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
