Question

Using C++ write the following program: 1) For the song program below, on a separate line...

Using C++ write the following program:

1) For the song program below, on a separate line write a function to quickly print the list of Streaming Services in your Song class, do not modify the program.

2). The Duration in your Song class contains minutes and seconds. Create a data structure called Duration to group the data, do not modify the program but with it on a separate line.

#include<iostream>
using namespace std;
struct Song
{
   string song_title;
   string performer;
   string writers;
   string streaming;
   string genre;
   string duration;
};
int main()
{
   struct Song s;
   cout<<" enter song title :";
   cin>>s.song_title;
   cout<<" enter performer : ";
   cin>>s.performer;
   cout<<" enter writers";
   cin>>s.writers;
   cout<<"enter streaming services : ";
   cin>>s.streaming;
   cout<<" enter genre : ";
   cin>>s.genre;
   cout<<"enter Duration : ";
   cin>>s.duration;
  
   cout<<"\n song title :"<<s.song_title;
   cout<<"\n performer : "<<s.performer;
   cout<<"\n writers : "<<s.writers;
   cout<<"\nstreaming services : "<<s.streaming;
   cout<<" \ngenre : "<<s.genre;
   cout<<"\nDuration : "<<s.duration;
   return 0;
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<iostream>

using namespace std;

void printServices(string);

struct Duration

{

int minutes;

int seconds;

};

struct Song

{

string song_title;

string performer;

string writers;

string streaming;

string genre;

struct Duration d;

};

int main()

{

struct Song s;

cout<<" enter song title :";

cin>>s.song_title;

cout<<" enter performer : ";

cin>>s.performer;

cout<<" enter writers";

cin>>s.writers;

cout<<"enter streaming services : ";

cin>>s.streaming;

cout<<" enter genre : ";

cin>>s.genre;

cout<<"enter minutes of Duration : ";

cin>>s.d.minutes;

cout<<"enter seconds of Duration : ";

cin>>s.d.seconds;

cout<<"\n song title :"<<s.song_title;

cout<<"\n performer : "<<s.performer;

cout<<"\n writers : "<<s.writers;

cout<<"\nstreaming services : \n";

printServices(s.streaming);

cout<<" \ngenre : "<<s.genre;

cout<<"\nDuration : "<<s.d.minutes<<":"<<s.d.seconds;

return 0;

}

void printServices(string list){

for(int i=0;i<list.length();i++){

if(list[i]==',')

cout<<"\n";

else

cout<<list[i];

}

}

Add a comment
Know the answer?
Add Answer to:
Using C++ write the following program: 1) For the song program below, on a separate line...
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 output of following program in C# afterremoving error if any. Note: Be sum of first...

    Write output of following program in C# afterremoving error if any. Note: Be sum of first two digit of your Roll no. Run the code after entering the value of B. Do not show error because of B. #include <iostream> using namespace std; class stud { public: char name[30.clas[10]; int rolage: void enter() { cout<<"Enter Student Name: "; cin>>name; cout<<"Enter Student Age: "; cin>>age; cout<<"Enter Student Roll number: "; cin>>rol; cout<<"Enter Student Class Year: "; cin>>clas; } void display {...

  • Fix my code, if I the song or the artist name is not on the vector,...

    Fix my code, if I the song or the artist name is not on the vector, I want to user re-enter the correct song or artist name in the list, so no bug found in the program #include <iostream> #include <vector> #include <string> #include <algorithm> using namespace std; class musicList{ private: vector<string> songName; vector<string> artistName; public: void addSong(string sName, string aName){ songName.push_back(sName); artistName.push_back(aName); } void deleteSongName(string sName){ vector<string>::iterator result = find(songName.begin(), songName.end(), sName); if (result == songName.end()){ cout << "The...

  • Having code issues wth my C++ program. My program checks if two binary trees are similar...

    Having code issues wth my C++ program. My program checks if two binary trees are similar and if they're not they return false. My program is return true with different binary trees. Could use some help thanks #include <iostream> #include <string> using namespace std; //Struct of Nodes struct BinarySearchTree { int data; BinarySearchTree *left; BinarySearchTree *right; }; // Inserting nodes into BST BinarySearchTree* insert( BinarySearchTree* node, int val) { if (node == NULL) { BinarySearchTree *newNode = new BinarySearchTree(); newNode->data...

  • Write following program using Switch statement. #include <iostream> using namespace std; int main() int number; cout...

    Write following program using Switch statement. #include <iostream> using namespace std; int main() int number; cout << "Enter an integer cin >> number; if (number > B) cout << You entered a positive integer: " << number << endl; else if (number (8) cout<<"You entered a negative integer: " << number << endl; cout << "You entered e." << endl; cout << "This line is always printed." return 0;

  • Can someone please tell me why the calculation for earnings is not coming through at the...

    Can someone please tell me why the calculation for earnings is not coming through at the end of the program? Thank you. //This program should tell us about streaming services #include <iostream> #include <iomanip> #include <string> using namespace std; int main() {    int choice, streams;    double earnings;    string song;    string artist;    string streamingService;       const int Tidal = 0.01250;    const int Amazon = 0.00402;    const int Apple_Music = 0.00735;    const int...

  • Write the missing statements for the following program. #include <iostream> using namespace std; int main(void) {...

    Write the missing statements for the following program. #include <iostream> using namespace std; int main(void) { int Num1; cout << "Enter 2 numbers: ";    cin >> Num2; if (Num1 < Num2) cout << "Smallest number is " << Num1; else cout << "Smallest number is " << Num2;    return 0; }

  • Using an object-oriented approach, write a program to read a file containing movie data (Tile, Director,...

    Using an object-oriented approach, write a program to read a file containing movie data (Tile, Director, Genre, Year Released, Running Time) into a vector of structures and perform the following operations: Search for a specific title Search for movies by a specific director Search for movies by a specific genre Search for movies released in a certain time period Search for movies within a range for running time Display the movies on the screen in a nice, easy to read...

  • /* I'm trying to write this program here but my problem is getting the program to...

    /* I'm trying to write this program here but my problem is getting the program to save the user input to "int data" but cannot because it is part of the struct. What do I have to do in order to get this to work? (Language is C++) Write a program that prompts the user to enter numbers on the screen and keep adding those numbers to a linked list. The program stops when user enters -999. Hint: Use a...

  • Write a C++ Program. You have a following class as a header file (dayType.h) and main()....

    Write a C++ Program. You have a following class as a header file (dayType.h) and main(). #ifndef H_dayType #define H_dayType #include <string> using namespace std; class dayType { public:     static string weekDays[7];     void print() const;     string nextDay() const;     string prevDay() const;     void addDay(int nDays);     void setDay(string d);     string getDay() const;     dayType();     dayType(string d); private:     string weekDay; }; #endif /* // Name: Your Name // ID: Your ID */ #include <iostream>...

  • This program illustrates dynamic variables #include <iostream> using namespace std; int main () {    int...

    This program illustrates dynamic variables #include <iostream> using namespace std; int main () {    int *p1;    p1 = new int;             // Variables created using the new operator are called dynamic variables    cout << "Enter an integer \n";    cin >> *p1;    *p1 = *p1 + 7;    cout << << "Your input + 7 = " << *p1 << endl;    delete p1;                // Delete the dynamic variable p1 and return the memory occupied by p1 to...

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