To the attached music management system www ww program in the text; www www -Add a function that will allow us to add the prices of music; www w m www w ww ww m m -Add a function that will give the total price of the music the user bought.
#include<bits/stdc++.h>
using namespace std;
// Class representing music data
class Song {
public:
string musicName, musicDescription;
};
// Function to take input for music description
Song addDescription()
{
Song s1;
cout<<"Enter the Music name : ";
cin>>s1.musicName;
cout<<"Enter the Music description : ";
cin>>s1.musicDescription;
return s1;
}
// Function to write music object details into a txt file
void storeInfoToDatabase(Song s){
ofstream fileObject;
// Opening the file in append mode
fileObject.open("Database.txt", ios::app);
fileObject << s.musicName;
fileObject << " ";
fileObject << s.musicDescription;
fileObject << "\n";
}
// Driver Function
int main(){
Song s = addDescription();
storeInfoToDatabase(s);
cout<<"Data written into file succesfully...";
return 0;
}
Step by step
Solved in 2 steps with 4 images