Question: I need my code made into a Heirarchy Chart. C++ CODE: #include #include using namespace std; struct music { string title; string artist; string genre;
I need my code made into a Heirarchy Chart.
C++ CODE:
#include
#include
using namespace std;
struct music
{
string title;
string artist;
string genre;
float len;
};
void menu(){
cout<<"Enter the corresponding key for the operation you want to do ";
cout<<"1. Manage Playlist ";
cout<<"2. Manage Songs ";
cout<<"3. Display Playlist ";
cout<<"4. Exit the program. ";
}
string manage_playlist(){
string pName;
cin.ignore();
cout << "Insert a name for this playlist: ";
getline (cin, pName);
cin.clear();
return pName;
}
void manage_songs(music arr_str[],int i){
for(int k=0;k<3;k++,i++)
{
cout << "Insert the title of the first song: ";
cin.ignore();
getline (cin, arr_str[i].title);
cout << "Insert the artist name of the first song: ";
cin.ignore();
getline (cin, arr_str[i].artist);
cout << "Insert the genre of the first song: ";
cin.ignore();
getline (cin, arr_str[i].genre);
cout << "Insert the length of the first song: ";
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 << "Choose your favorite genre" << endl;
cout << " 1 : " << sGenre1 << endl;
cout << " 2 : " << sGenre2 << endl;
cout << " 3 : " << sGenre3 << endl;
cout << " 4 : Exit program " << endl;
int choice = 0;
cout << "Your choice: ";
cin>>choice;
switch(choice)
{
case 1:
cout << "Wise!" << endl;
break;
case 2:
cout << "Rad!" << endl;
case 3:
cout << "Tubular!" << endl;
break;
case 4:
cout << "Exiting program..." << endl;
break;
}
playlistAverage = totalLength / 3;
for(int k=0;k<3;k++)
{
cout << "Name of the playlist: " << pName << " ";
cout << k+1 << ".-------------------------------------- ";
cout << " Title: \t" << arr_str[k].title << " ";
cout << " Artist:\t" << arr_str[k].artist << " ";
cout << " Genre: \t" << arr_str[k].genre << " ";
cout << " Length:\t" << arr_str[k].len << " ";
}
cout << "The playlist named " << pName << " has a total length of " << totalLength << " minutes. ";
cout << "Also, the playlist named " << pName << " has an average length of " << playlistAverage << " minutes ";
}
}
int main()
{
music arr_str[10];
string pName;
float totalLength = 0.0;
int newChoice=0, i=0, k=0;
cout << "############################################################ ";
cout << " Welcome to the DJ Dance Playlist Manager ";
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
