im confused as to how to get the pointers to save values... anyone with helpful advice??? this is where i have gone so far....
#include <iostream>
#include <cstdlib>
using namespace std;
int main () {
typedef struct dataNode {
char arriveCity[30];
char departCity[30];
int totalPassengers;
int passengers;
int flightNumber;
struct dataNode *next;
} dataNode;
dataNode *newNode;
newNode = new dataNode;
int option1 = 0, option2 = 0;
char searchCity [30];
search1: // for the goto statement on invalid choice
option1 = 0;
cout << endl;
cout << "Welcome to the JHD International Airport! How can we be of assistance?" << endl;
cout << "Please select the best option for you:" << endl;
cout << " 1. Create a new flight record." << endl;
cout << " 2. Delete an existing flight record." << endl;
cout << " 3. Search for a flight." << endl;
cout << " 4. End current program session." << endl;
cin >> option1;
cout << endl;
if (option1 == 1) {
flight: // start of flight creation
cout << "Please input the six digit flight number (100000 - 999999): ";
cin >> (*newNode).flightNumber;
if (newNode -> flightNumber < 100000 || newNode -> flightNumber > 999999) {
cout << "Invalid flight number reference" << endl << endl;
goto flight; // restarts flight creation
}
cout << endl << "What is the departure city? ";
cin >> (*newNode).departCity;
cout << endl << "What city is the flight destination? ";
cin >> (*newNode).arriveCity;
cout << endl << "What is the maximum capacity for this flight? ";
cin >> (*newNode).totalPassengers;
cout << endl << "How many passengers currently have tickets? ";
cin >> (*newNode).passengers;
cout << endl;
system("cls");
goto search1; //returns you to main menu
}
else if (option1 == 2) {
// reenter:
cout << "Which flight would you like to delete? ";
/* cin >> ;
if ( < 100000 || > 999999) {
cout << "Invalid entry, please re-enter. "
goto reenter; // restarts deletion
}
else {
}
*/
}
else if (option1 == 3) {
search2: // for the goto statement on invalid choice
cout << "Please select the search option of your choice:" << endl;
cout << " 1. Display all flight records." << endl;
cout << " 2. Display all departing flights from a city." << endl;
cout << " 3. Display all open flights." << endl;
cout << " 4. Go back to the main menu." << endl;
cin >> option2;
cout << endl;
if (option2 == 1) {
if (newNode != NULL) {
while (newNode != NULL){
cout << newNode -> flightNumber << " " ;
cout << newNode -> departCity[30] << " ";
cout << newNode -> arriveCity[30] << " ";
cout << newNode -> passengers << " ";
cout << newNode -> totalPassengers << " " << endl;
newNode = newNode -> next;
}
cin >> option2;
}
else {
cout << "No flights have been entered. " << endl;
goto search1;
}
}
else if (option2 == 2) {
cout << "What city do you wish to search for?" << endl;
cin >> searchCity [30];
cout << endl;
if (searchCity[30] == (*newNode).departCity[30]) {
cout << newNode -> departCity[30] << endl;
goto search1;
}
else {
cout << "I'm sorry. We currently have no flights out of that city." << endl << endl;
goto search1; // takes you back to the main menu
}
}
else if (option2 == 3) {
}
else if (option2 == 4) {
system("cls");
goto search1; // takes you back to the main menu
}
else {
cout << "You have selected an invalid option. Please choose again." << endl << endl;
goto search2; // restarts flight search menu
}
}
else if (option1 == 4) {
cout << "Thank you. Goodbye." << endl;
goto end; // ends the program
}
else {
cout << "You have selected an invalid option. Please choose again." << endl << endl;
system("cls");
goto search1; // restarts main search menu
}
end: // for the goto statement to end program
return 0;
}