First, let me say hello! I am transferring to a California State Uni this fall, my major is information technology(business) and I have just finished my first C++ course at the local JC.
I feel like I am nearing the apex on the "hump" to getting C++ to click for me, and beaing able to "put it all together". Thanks you for the help.
This is a problem I was given in a C++ course last semester and I sill have not finished writing it because I still haven't been able to put it all together.
I am trying to write a program that:
gives users 3 choices
1 view existing passenger list
2 book new passenger list
3 quit
1 I have created manifest.txt, a text file with passenger preferences.
2 five pieces of info: first, last, smoking, row, seat.
3 This part was easy and I have a handle on it I think...
I would like to have a waiting list for smoking and non for the overflow of passengers.
Also I would like to give choice of seats. if seat is occupied, place passenger in next neatest seat to request.
This is what I have got so far. Thanks for your time.
--------------------------------------------------------------------------
//
// FinalTest.cpp -- Compile with manifest.txt
// This program gives choice to user to takes data from
// user input or existing list of passengers/preferences.
// Compile with manifest.txt
// Darryn Yost
// include all necessary external files
// define variables and constants
// define structure
// begin main
// define passenger list as a structure
// call menu
// get menu choice
// based on choice - do something
// view information
// book a new flight
// quit program
// while choice does not = Qq
// define the input file
// read from it (if possible) and fill the array
// display the names
// end main
// need to get around to filling the seats based on passenger preference - or put on
// waiting list if all seats are filled
// also need to view non-smoking list - smoking list - waiting list
const int SIZE = 25;
const int passNum = 2; // must contain the number of passengers on list
char choice;
char q;
char Q;
int k;
int x =0 ;
struct passList // structure for passenger information
{
char fName[SIZE];
char lName[SIZE];
char pref;
int row;
int seat;
};
void showMenu(); // function prototype
void displayLine(); // function prototype
void bookNewmenu(int x, passList[]); // function prototype
//void fastfunctiontest(); // function prototype
void fastfunctiontest();
// cout << fastfunctiontest << endl;
// void fastFlight(passList); testing...
int main()
{
passList passInfo[passNum]; // declare the passenger list (an array of structure)
// perhaps the loop to show the menu, get the choices and do the data entry should be here
showMenu(); // SHOW MENU CHOICES
cin >> choice;
switch(choice)
{
case 'A' :
case 'a' : for (k = 0; k < passNum; k++) // view passenger information list
{
cout << "Run list from file" << endl;
system("pause");
system("CLS");
break;
}
case 'B' :
case 'b' : for (k = 0; k < passNum; k++) // book new flight menu
// should loop inside here to do the booking as long as ?????
{
//int fill_passInfo(passList passInfo[k], int SIZE)
cout << "New booking menu";
// function calls have the name of the function and the parameters (if any)
// do not put VOID in front of a function call
// VOID belongs in definitions (prototypes)
bookNewmenu(k ,passInfo ); // programmer defined function definitions
system("pause");
system("CLS");
cout << "back from the function";
cout << passInfo[k].lName << '\t' << passInfo[k].fName << '\t' << passInfo[k].pref;
break;
}
case 'Q' :
case 'q' :
{
cout << "Quitting the program\n"; // Quit
// exit();
}
system("pause");
system("CLS");
break;
default : cout << "This is not a choice. \n";
}
while(choice !='Q' && choice != 'q') // terminate?
{
passInfo[passNum]; // const passNum = 41 type passList objects
ifstream manifest; // manifest is the ifstream variable
manifest.open("manifest.txt"); // opens the file(manifest) for data storage
if (!manifest.is_open()) // FAILED to open file
{
cout << "Could not open file " << endl;
cout << "Program terminating.\n";
exit(EXIT_FAILURE);
}
// ***Function definitions***
void bookNewmenu(int x ,passList passInfo[] ) // programmer defined function definitions
// recommend that you print the passInfo list both here and
// back in main - so you can be sure that the stuff is there
{
cout << "\t\tFAST FLIGHT AIRLIINES\n"
"\t -- Passenger Information System --\n"
" -- Book New Flight --\n";
cout << "Please enter your first name: ";
cin >> passInfo[x].fName;
cout << "Please enter your last name: ";
cin >> passInfo[x].lName;
cout << "Please choose Smoking or Non-smoking: ";
cin >> passInfo[x].pref;
cout << "Please enter seat number: ";
cin >> passInfo[x].row;
cout << "Please enter row number: ";
cin >> passInfo[x].seat;
cout << passInfo[x].lName << '\t' << passInfo[x].fName << '\t' << passInfo[x].pref;
cout << '\t' << passInfo[x].row << '\t' << passInfo[x].seat << endl;
} // end of BookNewmenu
int fill_array(int fillarray[], int passNum) // trying to figure out how to fill this array
void showMenu() // programmer defined function definition THIS WORKS!
{
cout << "\t\tFAST FLIGHT AIRLIINES\n"
"\t -- Passenger Information System --\n"
"Welcome to the Fast Flight passenger information manager\n"
"__________________________________________________________\n"
"\nPlease choose from the following options: \n\n"
"\ta - View Passenger Information List\n\n"
"\tb - Book new flight\n\n"
"\tq - Quit program\n\n\n"
"Please enter your choice:__\b";
return;
} // end of showMenu function
void displayLine()
{
cout << "\t\n___________________________________________________________\n"
<< endl;
return;
} // end of displayLine function
Please edit your post and put code tags [code]around your code[/code] like this. That makes it do syntax highlighting so that it is much easier to read all your code.