Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using the code you created for the %u201CProgramming Warm-Up Exercises%u201D you

ID: 3537730 • Letter: U

Question

Using the code you created for the %u201CProgramming Warm-Up Exercises%u201D you are to:

1.       Create a constructor that will take in the following arguments in this order:

a.       Title

b.      Album

c.       Artist

d.      Minutes

e.      Seconds

f.        Category

2.       Add a PrintSong function to your Song class. This function will print out all the information about the song.

3.       If you have not done so, add preprocessor directives to your song.h file.

4.       Use the main function as specified below. (Do not add anything to the int main block. You may modify the code around it but do not modify the contents of the main function below)

5.       Run the program and take a screen shot. Paste a copy of the screen shot in your homework submission file.

int main()<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

{

       // Create instance of class Song

       Song mySong("One", "And Justice For All", "Metallica", 7, 25, METAL);

       // Print Song Information

       mySong.PrintSong();

       cin.get();

       return 0;

}

Explanation / Answer

#include<iostream>
using namespace std;
enum Categories{METAL, CLASSIC, ROCK, POP};
string cat[]={"METAL", "CLASSIC", "ROCK", "POP"};
class Song
{
private:
string Title;
string Album;
string Artist;
int Minutes;
int Seconds;
Categories Category;
public:
Song(string tit,string alb,string art,int min,int sec,Categories cat)
{
Title = tit;
Album = alb;
Artist=art;
Minutes=min;
Seconds=sec;
Category=cat;
}
void PrintSong()
{
cout << "song title is " << Title << " from the album " << Album << " by " << Artist << " has length of " << Minutes << " Minutes "
<< Seconds << " Seconds " << " belong to category " << cat[Category] << endl;
}
};
int main()
{
       // Create instance of class Song
       Song mySong("One", "And Justice For All", "Metallica", 7, 25, METAL);
       // Print Song Information
       mySong.PrintSong();
       cin.get();
       return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote