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

Hi. I\'m working on this project but I\'m very new to coding so I\'m having a lo

ID: 3663209 • Letter: H

Question

Hi. I'm working on this project but I'm very new to coding so I'm having a lot of difficulties. I copy down below the project decription and I hope someone could help me finishing this by doing a step by step instruction. It'll be highly appreciated if anyone can actually write the whole code for this and from there I can work my way into understanding how to write a code for problems like this. But for me, it's great enough if anyone could give me a detail step by step instruction on how to start and what to start with when doing this project. Thank you in advance. And this is due pretty soon so I hope someone will be able to help me ASAP. ^_^

(I'm studying C++ using Visual Studio and I believe these are the basics in C++. However, I'm new so I'm trying to get used to it)


Goals for This Project:
Break tasks down into functions
Master pass by reference or pass by value
Use character arrays and <cstring>
Use struct to model composite data type
Use array of objects to model a collection
File input/output

Problem You Need to Solve for This Lab:
You are asked to write an app to keep track of a relatively small music library. The app should load song information from a data file once the app is started. It should allow user to view, add, remove, and search for songs. The app should save the data back to the same data file when the program exits.
What Your Program Should Do:
Write an interactive text based menu interface (using a loop) that will allow the user to
Enter information for a new song
Display information for all the songs in the database with index for each song
Remove a song by index
Search for songs by a certain artist
Search for songs by a certain album
Quit
For each song, you need to keep track of:
title
artist
duration
album

Allow the program to keep looping until user wants to quit. When the program starts, it should load the tasks from external file ("songs.txt") into memory. When user enters information about the new song, the program needs to read them in, save them in memory and eventually write them to the external data file ("songs.txt"). The file format could look like:

Stereo Hearts;Gym Class Heroes;3;34;The Papercut Chronicles II Counting Stars;OneRepulic;4;17;Native

The ';' is used as a delimiter or field separator. Each record ends with a new line character. Also the above sample data came from my teen son, not a reflection of your instructor’s music taste
Some Implementation Requirements:
1. Write at least four functions WITH arguments for this assignment.
2. Use struct named Song to model each song
3. Use array of structs to model the collection of songs.
4. Hint: In this assignment, some data fields may have multiple words in it. Therefore, you now SHOULD read using the 3 argument version of get.
5. Watch out. When using the 3 argument version of get you need to make sure to remove the delimiter or newline. Therefore, anytime you read (even a confirmation message), make sure to eat the newline using cin.ignore(...)!
6. Make sure to have a delimiter written between each item in the file – like a newline. This will be important when you read the information back from the file.
7. For submission, your data file should contain a sufficient set of test data. It should have test cases for same artist with multiple songs and same album with multiple songs in it.

Explanation / Answer

#include <iostream>

#include <string>

#include <vector>

#include <algorithm>

#include <fstream>

#include <cstdlib>

Using namespace std;

nt option;
int menu
int counter = 0;
Song collection[200];

Struct Song

{

String title,

           artist,

           album;

double duration;

public:

Song(); //default constructor
Song(string aTitle, string anArtist, string anAlbum, double aDuration);

string getTitle()const;
string getArtist()const;
string getAlbum()const;

string getDuration()const;
void setTitle(string newTitle);
void setArtist(string newArtist);
void setAlbum(string newAlbum);
void setDuration(double newDuration);
string toDisplayString() const;

void AddNewsong();
void Remove(int counter);
void Display();

void SearchbyArt(string anArtist);

void SearchbyAlb(string anAlbum);
void Exit();

private:

string title;
string artist;
string album;

double duration;

};

void main()

{

cout<<"1)Enter information of New Song"<<endl;

cout<<"2)display information of all songs with index"<<endl;

cout<<"3)Remove a song by index"<<endl;    

cout<<"4)Search a Song by certain artist"<<endl;

cout<<"5)Search a Song by certain album "<<endl;

cout<<"6)Exit Program"<<endl

cin >> option;

switch (option) {
case 1:
cout << " Add a new songs information" << endl;
void AddNewsong ();
counter++;
break;
case 2:
cout << " Remove a song by particular index" << endl;
void Remove(int counter);
break;
case 3:
cout << " Display a all songs" << endl;
void Display();
break;

case 4: “ search a song by certain Artist”<<endl;

void SearchbyArt(string artist);

break;

case 5: “ search a song by certain Album”<<endl;

void SearchbyAlb(string album);

break;
case 6:
cout<< " Quit" << endl;
void Exit();
break;
default:
cout << " Input a value between 1-6" << endl;
return menu();

}

void AddNewsong()
{

cout << " Enter song title:" << endl;
getline(cin, title);
collection[counter].setTitle(title);


cout << " Enter song artist:" << endl;
getline(cin, artist);
collection[counter].setArtist(artist);

cout << " Enter song album:" << endl;
getline(cin, album);
collection[counter].setAlbum(album);

cout<< “ enter duration of song:”<<endl;

getLine(cin,duration);

collection[counter].setDuration(duration);

return menu();
}

void Remove(int counter);
{
cout << " Enter index of song you want to delete" << endl;
getline(cin, counter);
collection[counter].remove();

return menu();
}

void DisplayallSongs(int counter);
{
int i;
Song list;

cout << " Here are the songs in your collection: " << endl;

for(i = 0; i <collection.length(); i++)
{
list = collection[i];

cout << "Title:" << list.getTitle() << endl;
cout << "Artist:" << list.getArtist()<< endl;
cout << "Album:" << cout << list.getAlbum() << endl;
cout<<”duration:”<<cout<<list.getDuration()<<endl;
return menu();
}
void SearchbyArt(string artist)

{

cout<<” please enter the artist name:”<<endl;

getLine(cin,artist);

for(i = 0; i <collection.length(); i++)

{

if(collection[i].getArtist() == artist)

{

cout<<”the song by the artist is:”<<endl;

cout<<collection[i].getTitle();

}

}

}

void SearchbyAlb(string album)

{

cout<<” please enter the album name:”<<endl;

getLine(cin,album);

for(i = 0; i <collection.length(); i++)

{

if(collection[i].getAlbum() == album)

cout<<”the song of the album is:”<<endl;

cout<<collection[i].getTitle();

}

}

void Exit()
{

}


Song:: Song()
{
title= " ";
artist = " ";
album = " ";
}

Song::Song(string aTitle, string anArtist, string anAlbum,double aDuration)
{

title = aTitle; //Assing parameters
artist = anArtist;
album = anAlbum;

}
string Song::getTitle() const
{
return title;
}

void Song:: setTitle(string newTitle)
{
title= newTitle;
}

string Song::getArtist() const
{
return artist;
}

void Song:: setArtist(string newArtist)
{
artist=newArtist;
}

string Song::getAlbum() const
{
return album;
}
void Song::setAlbum(string newAlbum)
{
album= newAlbum;
}
double Song::getDuration() const

{

Return duration;

}

Void Song::setDuration(double newduration)

{

Duration =newDuration;

}
string Song::toDisplayString() const
{
string view = " Title: " + title;
view += " Author: " + artist;
view += " Album: " + album;

View+=” Duration:” +duration+ " ";
return view;
}

Note: to output it to Songs.txt file we can use:

Ofstream fout(“songs.txt”);

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

{

fout<<collection[i];

}

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