I need help with this program. I'm a little confused of what this program is asking including pointers and linked list. These are the requirements of the program.
---You are to create a program which allows the user to enter data for Noah’s Ark, a company which boards animals. The input to the program contains a list of animals currently boarded, including the tracking number of the animal, the type of animal boarded, and the daily boarding charge for the animal. After the data entry is complete, the items entered are stored in a linked list and printed to the monitor.
---1. You must use a structure which includes the following elements:
a. the tracking number of the animal integer
b. the type of animal boarded character array
c. the daily boarding charge for the animal double
d. pointer to next record pointer
2. One global variable may be used. This variable should represent a pointer to the head of the linked list.
3. Two functions should be included to perform the following:
a. insert an item into a linked list;
b. display the values of all of the members of the list to the monitor (as described in the “output” section);
4. Create a program that prompts the user to enter the required data (as described in the “input” section). Once the data has been entered for an item, the appropriate function should be called to insert the item at the head position of a linked list. The prompts for data should be placed inside a “while” loop which asks the user for additional items to be entered. Once the data entry is completed, the appropriate function should be called to display the data in a formatted manner to the monitor.
This is how far I've gotten, I'm confused on how to link the lists and point to them, I used to just having the user enter in information and then returning that information at the end of the program.
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
|
#include <iostream>
#include <string>
using namespace std;
struct node
{
int trackingnumber;
char* typeofanimal;
double boardingcharge;
node *link
};
node *n, *a, *c;
void printList(node *);
int main()
{
cout<<" Please enter the Tracking Number: "<<endl
cin<<trackingnumber<<endl;
cout<<" Please enter the Type of Animal: "<<endl
cin<<typeofanimal<<endl;
cout<<" Please enter the boarding charge: "<<endl
cin<<boardingcharge<<endl;
cout<< "Do you wish to enter any more information?"
<< endl;
cout << "Enter 'Y' or 'N'" << endl;
cin >> ContinuationFlag;
return 0;
}
|