Hello,
I am learning C++ and pointers and arrays have been hard for me to grasp on.
Last week, my teacher assigned us a lab in which we used dynamic memory to make a list of numbers which I couldnt not finish because I didnt know where to start and what to do. My teacher tried helping but it was too late. My next assignment is similar and I am trying to start on it but cant seem to know wehre to start. I have read multiple tutorials and saw multiple videos and understand pointers and array but still need help. I am not asking someone to give me the code but help me get started. Please help and thank you in advance. I am so lost :(.
Write a program that creates a database of Compact Disk (CD) information. Your database will consist of the following data elements:
string CDTitle[50];
string Artist[50];
int number_of_songs[50];
Example or forth entry in CD Database:
CDTitle[3]: "Greatest Hits"
Artist[3]: "aba"
number_of_songs[3]: 12
Create a useable user interface that allows the user to input data into each CD Entry, modify a CD entry, and print out the entire database of CDs.
Thus a menu MIGHT look like this:
1. Add CD
2. Print out CD list
3. Modify CD entry
4. Quit program
HINT: You must have some sort of variable that keeps track of the number of CDs entered. This will start out at 0 and increment by 1 each time a CD is entered.
Feel free to add extra features if you wish.
[/quote]
This is what I have so far,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
#include <iostream>
#include <string>
using namespace std;
int main()
{
int selection;
int counter = 0;
string CDTitle[50];
string Artist[50];
int number_of_songs[50];
int database[1000];
do
{
cout<<"Menu -------------"<<endl;
cout<<"<1>Add CD"<<endl;
cout<<"<2>Print Out CD List"<<endl;
cout<<"<3>Modify CD Entry"<<endl;
cout<<"<4>Quit"<<endl;
cin>>selection;
cout<<endl<<endl;
if(selection == 1)
{
cout<<"Enter CD Title";
getline(cin, CDTitle);
cout<<"Enter Artist";
getline(cin, CDTitle);
cout<<"Enter number of songs.";
cin>>number_of_songs[counter];
counter++;
}
else if(selection == 2)
{
for(int i = 0; i<=50; i++)
cout<<CDTitle[i];
}
else if(selection == 3)
{
}
else if(selection == 4)
{
return 0;
}
}while(selection != 4);
}
|