Question: I need to add loops to validate my data. Add a menu to my program that allows users to use the various features or exit

I need to add loops to validate my data. Add a menu to my program that allows users to use the various features or exit the program.

I am making a DJ playlist and need to add the following features by adding loops; options to manage playlists, manage songs, display playlists, and so forth, or exit the program.

Below is my code so far for the entire program I have made, I just need help with the loops and adding those features.

#include

#include

using namespace std;

int main()

{

string pName;

string sTitle1, sTitle2, sTitle3;

string sArtist1, sArtist2, sArtist3;

string sGenre1, sGenre2, sGenre3;

float sLength1, sLength2, sLength3;

float totalLength;

float playlistAverage;

cout << "############################################################ ";

cout << " Welcome to the DJ Dance Playlist Manager ";

cout << "############################################################ ";

cout << "Insert a name for this playlist: ";

getline (cin, pName);

cout << "Insert the title of the first song: ";

getline (cin, sTitle1);

cout << "Insert the artist name of the first song: ";

getline (cin, sArtist1);

cout << "Insert the genre of the first song: ";

getline (cin, sGenre1);

cout << "Insert the length of the first song: ";

cin >> sLength1;

fflush(stdin);

cout << " Insert the title of the second song: ";

getline (cin, sTitle2);

cout << "Insert the artist name of the second song: ";

getline (cin, sArtist2);

cout << "Insert the genre of the second song: ";

getline (cin, sGenre2);

cout << "Insert the length of the second song: ";

cin >> sLength2;

fflush(stdin);

cout << " Insert the title of the third song: ";

getline (cin, sTitle3);

cout << "Insert the artist name of the third song: ";

getline (cin, sArtist3);

cout << "Insert the genre of the third song: ";

getline (cin, sGenre3);

cout << "Insert the length of the third song: ";

cin >> sLength3;

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;

break;

case 3:

cout << "Tubular!" << endl;

break;

case 4:

cout << "Exiting program..." << endl;

break;

}

totalLength = sLength1 + sLength2 + sLength3;

playlistAverage = sLength1 + sLength2 + sLength3 / 3;

cout << "Name of the playlist: " << pName << " ";

cout << "1.-------------------------------------- ";

cout << " Title: \t" << sTitle1 << " ";

cout << " Artist:\t" << sArtist1 << " ";

cout << " Genre: \t" << sGenre1 << " ";

cout << " Length:\t" << sLength1 << " ";

cout << "2.-------------------------------------- ";

cout << " Title: \t" << sTitle2 << " ";

cout << " Artist:\t" << sArtist2 << " ";

cout << " Genre: \t" << sGenre2 << " ";

cout << " Length:\t" << sLength2 << " ";

cout << "3.-------------------------------------- ";

cout << " Title: \t" << sTitle3 << " ";

cout << " Artist:\t" << sArtist3 << " ";

cout << " Genre: \t" << sGenre3 << " ";

cout << " Length:\t" << sLength3 << " ";

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";

}

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!