itunes database

Hi, i received this homework assignment and need some help. I need to create an iTunes database that can hold 10 song/artist/album records as well as allow the user to change the song/artist/album. This is what i have so far. I dotn understand functions very well and know I need some but I dont know how to create them. Any help would be great. Thanks

#include <iostream>
#include <string>
using namespace std;

int printMenu( );
void printDatabase( );
void changesongName( );
void changeartistName( );
void changealbumName( );

//Arrays with the song name, artist, and album
//array has 10 elements ranging from 0 to 9
string songName[10];
string artistName[10];
string albumName[10];
//start of main
int main()
{
//fill the arrays
songName[ 0 ] = "Octavarium";
artistName [ 0 ] = "Dream Theater";
albumName [ 0 ] = "Octavarium";

songName [ 1 ] = "Stop";
artistName [ 1 ] = "Against Me";
albumName [ 1 ] = "New Wave";

songName [ 2 ] = "Southbound";
artistName [ 2 ] = "Allman Brothers Band";
albumName [ 2 ] = "Brothers and Sisiters";

songName [ 3 ] = "The Zephyr Song";
artistName [ 3 ] = "The Red Hot Chili Peppers";
albumName [ 3 ] = "By the Way";

songName [ 4 ] = "Dysentry Gary";
artistName [ 4 ] = "Blink 182";
albumName [ 4 ] = "Enema of the State";

songName [ 5 ] = "Kashmir";
artistName [ 5 ] = "Led Zeppelin";
albumName [ 5 ] = "Houses of the Holy";

songName [ 6 ] = "The Girl";
artistName [ 6 ] = "City and Colour";
albumName [ 6 ] = "Be me your Love";

songName [ 7 ] = "Up All Night";
artistName [ 7 ] = "Mac Miller";
albumName [ 7 ] = "Blue Slide Park";

songName [ 8 ] = "Yellow";
artistName [ 8 ] = "ColdPlay";
albumName [ 8 ] = "Parachutes";

songName [ 9 ] = "All the Above";
artistName [ 9 ] = "Maino";
albumName [ 9 ] = "If Tomorrow Comes";

int x;
while (true)
{
x = printMenu();
switch ( x )
{
case( 0 ): return 0;
case( 1 ):
{
printDatabase();
break;
}
case( 2 ):
{
changesongName();
break;
}
case( 3 ):
{
changeartistName();
break;
}
case( 4 ):
{
changealbumName();
break;
}}



}// end main

int printMenu();
{
int choice;
cout << " _________________________________ "<< endl;
cout << " | |"<< endl;
cout << "|| 0. Exit Program |"<< endl;
cout << "|| 1. Print Entire Database |"<< endl;
cout << "|| 2. Change Song |"<< endl;
cout << "|| 3. Change Artist |"<< endl;
cout << "|| 4. Change Album |"<< endl;
cout << "||_________________________________|"<< endl;
cout << "||||||||||||||||||||||||||||||||||| "<< endl;
cout << endl;
cout << "Please enter choice: ";
cin >> choice;
return choice;
}}
Have you covered struct or class?
no we have not
The local tutorial seems to cover everything. Check it out, if you're still stuck let us know.
http://www.cplusplus.com/doc/tutorial/functions/
i just dont understand what i would put in the functions
you would change the songname for example, by checking which song it is they want to change, and then asking them what they want to change it to.

for example, if they wanted to change the songname of Octavarium, some non-compilable code for you:

std::string userinput
std::cin >> userinput
songname[0] = userinput
how much of functions have you gone over? have you done things like
void whatever(int *number, char &array[]);
or just
void simple(int a, char b);

- this will determine how you make your functions
i just dont understand what i would put in the functions
Try reading the link before further comment.
for kbw: when he says
I dotn understand functions very well and know I need some but I dont know how to create them
i assumed he is new to functions, which means he has a limited knowledge of how to use them, therefore my question.
for dan: on the other hand since you defined global variables (personally i avoid them) your functions do not really need any arguments, if you declare them within main, then all you should need to do is return the string in the array you want to change song[i] into the changing value, so you would do
song[i] = changesongname(song[i]);
and so on. that is one of the ways for you to accomplish this.
this is what i came up with to change the song name, not sure whats wrong with it.
voidchangesongName(string songtoChange)
{
int x;
string "newSong";
cout << endl << "Please enter what song you'd like to change" << x;
cin >> songName[x];
cout << endl << "Please enter the new song name" << "newSong" ;
cin >> "newSong";
songName[ songtoChange ] = "newSong";
this may work as a function:::

void changeArtist ( )
{
int x;
string newArtist;
cout << "enter index #: ";
cin >> x;
cout << endl << "Please enter new song name: ";
cin >> newArtist;
artist[ x ] = newArtist;

if ((x >=0) && (x<=9))
{
cout << x << " " << song[ x ]<< " " <<artist [ x ] << " "<< album[ x ] <<endl;
}
}




the only thing you should need in main is
changeAlbum ( );

Am I right in thinking that if one array changes the other should match?

So if you changed the song to Dysentry Gary, the artist would automatically change to Blink 182 and the album to Enema of the State?

Or have I got that wrong?
ps if you use it change some of the wording bc most likely youre in my class
Topic archived. No new replies allowed.