Question

Please write this program in C++, thanks

Task 9.3 Write a complete C++ program to create a music player Your program should read in several album names, each album haOption 3: call a select track to play function that allows the user to choose an album and then a track to play. It should pr

Task 9.3 Write a complete C++ program to create a music player Your program should read in several album names, each album has up to 5 tracks as well as a genre. First declare genre for the album as an enumeration with at least three entries. Then declare an album structure that has five elements to hold the album name, genre, number of tracks, name of those tracks and track location. You can use the template given below, but highly recommended to use your own variable names and enumeration list. enum genret pop, Jazz, Classic); struct album string album name; genre kind; int track number; string tracks [51 string tracklocation; Declare a vector (user determines the number of albums at the runtime) of type album to create database for album. In main you should have four option: Option 1: call a function add_album it allows the user to enter the album details. Option 2: call a function named print_all album to print out the album details.
Option 3: call a select track to play function that allows the user to choose an album and then a track to play. It should print out When the user selects a track to play your program must call an external program to play the track Option 4: Quit nter the option: 1 to add an album 2 to print the album details 3 to play a track fron an album 4 to exit nter album name Dangerous Enter genrepop, 1 Jazz. 2 > Classic Enter nunber of tracks in the album Enter the names for these 3 tracks BlackOrWhite ealTheWorld ho IsIt Enter the file location of these tracks rack folderl Enter the option: 1 to add an album 2 to print the album details 3 to play a track fron an album 4 to exit me of the albumDangerous enre of the album pop of tracks racks are: Black0rWhite lealTheWorld hoIsIt racks are located at track folderi Enter the option: 1 to add an album 2 to print the album details 3 to play a track fron an album 4 to exit Enter hriller Enter genre pop. 1Jazz. 2 >Classic album nane Enter nunber of tracks in the album Enter the names for these 4 tracks P.Y.T eatIt illieJean umanNature Enter the file location of these tracks track folder2 Screen shot continue in the next page, these screen shots are taken from a single run.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Source Code::

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
enum genre{pop,Jazz,Classic}; //enum

//structure for album
struct album
{
    string album_name;
    genre kind;
    int track_number;
    string tracks[5];
    string tracklocation;
};

//vector for keeping the data of the all albums
vector<album> v;

//temporary x1
album x1;

//it will add the album in the vector
void add_album()
{
    int y;
    cout<<"Enter album name\n";
    cin>>x1.album_name;
    cout<<"Enter genre 0->pop, 1->Jazz, 2->Classic\n";
    cin>>y;
    x1.kind=(genre)y;   // typecasting for int to enum
    cout<<"Enter number of tracks in the album\n";
    cin>>x1.track_number;
    cout<<"Enter the name for these "<<x1.track_number<<" tracks\n";
    for(int i=0;i<x1.track_number;i++)
        cin>>x1.tracks[i];
    cout<<"Enter the file location of these tracks\n";
    cin>>x1.tracklocation;
  
    v.push_back(x1);// at the end of we puchback the x1 into the vector
}

//it will just print all the album are in the vector
void print_all_album()
{
    vector<album>::iterator itr;
    for(itr=v.begin();itr!=v.end();itr++)
    {
        cout<<"Name of the album : "<<itr->album_name;
        cout<<"\nGenre of the album : "<<itr->kind;
        cout<<"\nNo. of tracks      : "<<itr->track_number;
        cout<<"\nTracks are :\n";
        for(int i=0;i<itr->track_number;i++)
        cout<<itr->tracks[i]<<endl;
        cout<<"Tracks are located at "<<itr->tracklocation<<endl;
    }
}

// it will used for playing track and will print out a statement
void select_track_to_play()
{
   string s1,s2;
   cout<<"Enter the album name\n";
   cin>>s1;
   cout<<"Enter the track name\n";
   cin>>s2;
   cout<<"When the user selects a "<<s2<<" to play your program must call an external program to play the track\n";
   cout<<"play the track "<<s2<<endl;
}

int main()
{
    int ch;
    do{
    cout<<"\nEnter the option:\n ";
    cout<<"1 to add an album\n ";
    cout<<"2 to print the album details\n ";
    cout<<"3 to play a track from an album\n ";
    cout<<"4 to exit\n";
    cin>>ch;
    switch(ch)
    {
        case 1: add_album();
                break;
        case 2: print_all_album();
                break;
        case 3: select_track_to_play();
                break;
        default: cout<<"Invalid option\n";
    }
    }while(ch!=4);
    return 0;
}

output::

output's screenshot are taken in one execution of program

Enter the option: 1 to add an album 2 to print the album details 3 to play a track from an albunm 4 to exit 1 Enter album nam

Enter the option: 1 to add an album 2 to print the album details 3 to play a track from an album 4 to exit 1 Enter album name

Enter the option: 1 to add an album 2 to print the album details 3 to play a track from an album 4 to exit 2 ame of the album

Thank You!! if you liked the solution then please give the like to question

Add a comment
Know the answer?
Add Answer to:
Please write this program in C++, thanks Task 9.3 Write a complete C++ program to create a music player Your program sh...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C++ program that produces the following output: /* OUTPUT Enter your age: 21 Enter...

    Write a C++ program that produces the following output: /* OUTPUT Enter your age: 21 Enter the last name: Lee Hello Tom Lee. You are 21 years old. Press any key */   Declare an array named: firstName The array is a c_string, i.e., it is a null-terminated character array. The size of the array is 10. Assign a first name to it when it is declared.   Declare an array named: lastName The array is a c_string, The size of the...

  • C++ : Please include complete source code in answer This program will have names and addresses...

    C++ : Please include complete source code in answer This program will have names and addresses saved in a linked list. In addition, a birthday and anniversary date will be saved with each record. When the program is run, it will search for a birthday or an anniversary using the current date to compare with the saved date. It will then generate the appropriate card message. Because this will be an interactive system, your program should begin by displaying a...

  • *Answer must be in C* Write a complete program as follows (declare any necessary variables): Create...

    *Answer must be in C* Write a complete program as follows (declare any necessary variables): Create an array of doubles named “hummus” with 2 rows and 300 columns. Initialize all array elements to zero. Write a loop that will repeatedly ask the user to enter a value and store it in the first row of the array (do not overwrite previously entered values) until the whole first row is populated with the user input. (hint the loop should have the...

  • (C++) Write a program that declares a struct to store the data of a football player...

    (C++) Write a program that declares a struct to store the data of a football player (player’s name, player’s position, number of touchdowns, number of catches, number of passing yards, number of receiving yards, and the number of rushing yards). Declare an array of 10 components to store the data of 10 football players. Your program must contain a function to input data and a function to output data. Add functions to search the array to find the index of...

  • c++ CSI Lab 6 This program is to be written to accomplish same objectives, as did...

    c++ CSI Lab 6 This program is to be written to accomplish same objectives, as did the program Except this time we modularize our program by writing functions, instead of writing the entire code in main. The program must have the following functions (names and purposes given below). Fot o tentoutefill datere nedefremfite You will have to decide as to what arguments must be passed to the functions and whether such passing must be by value or by reference or...

  • Please help!! (C++ PROGRAM) You will design an online contact list to keep track of names...

    Please help!! (C++ PROGRAM) You will design an online contact list to keep track of names and phone numbers. ·         a. Define a class contactList that can store a name and up to 3 phone numbers (use an array for the phone numbers). Use constructors to automatically initialize the member variables. b.Add the following operations to your program: i. Add a new contact. Ask the user to enter the name and up to 3 phone numbers. ii. Delete a contact...

  • Please use C programming to write the code to solve the following problem. Also, please use the i...

    Please use C programming to write the code to solve the following problem. Also, please use the instructions, functions, syntax and any other required part of the problem. Thanks in advance. Use these functions below especially: void inputStringFromUser(char *prompt, char *s, int arraySize); void songNameDuplicate(char *songName); void songNameFound(char *songName); void songNameNotFound(char *songName); void songNameDeleted(char *songName); void artistFound(char *artist); void artistNotFound(char *artist); void printMusicLibraryEmpty(void); void printMusicLibraryTitle(void); const int MAX_LENGTH = 1024; You will write a program that maintains information about your...

  • Please write this in C. Write this code in Visual Studio and upload your Source.cpp file for checking (1) Write a program to prompt the user for an output file name and 2 input file names. The progra...

    Please write this in C. Write this code in Visual Studio and upload your Source.cpp file for checking (1) Write a program to prompt the user for an output file name and 2 input file names. The program should check for errors in opening the files, and print the name of any file which has an error, and exit if an error occurs opening any of the 3 For example, (user input shown in caps in first line) Enter first...

  • Write MIPS code, please. Following: Write a program to be used by the Wisconsin DNR to...

    Write MIPS code, please. Following: Write a program to be used by the Wisconsin DNR to track the number of Deer Hunting Licenses issued in a county and the state. It will display a menu with 5 choices numbered 1-5. They are (1) update the count, (2) display the number of licenses already issued to a county whose number is input, (3) display the county number and the number of licenses already issued to a range of counties whose starting...

  • (C++) Please create a tic tac toe game. Must write a Player class to store each...

    (C++) Please create a tic tac toe game. Must write a Player class to store each players’ information (name and score) and to update their information (increase their score if appropriate) and to retrieve their information (name and score).The players must be called by name during the game. The turns alternate starting with player 1 in the first move of round 1. Whoever plays last in a round will play second in the next round (assuming there is one).The rows...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT