Flight Reservation Console App

Download Documentation

 

[code language=”csharp”] /* Mark Hesser
* Nov 13, 2017
* Intro to P&L
* Flight Reservation */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace Flight_Reservation_Console
{
class Program
{
public static void Main(string[] args)
{
//Declarations
//File Paths
string path = Directory.GetParent(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)).FullName;
if (Environment.OSVersion.Version.Major >= 6)
path = Directory.GetParent(path).ToString();

string path_e = @"\Documents\Flight Reservation Data\economy data.txt", path_fc = @"\Documents\Flight Reservation Data\first class data.txt";
string path_s = @"\Documents\Flight Reservation Data\settings.txt";

//Creates Data Directory if it doesn’t exist
//Must be after File Path Declarations to Work
Directory.CreateDirectory(path + @"\Documents\Flight Reservation Data");

//Temp Variables
string temp_customer_name = "", temp_customer_address = "", temp_seatpref = "";
double temp_miles = 0; int temp_checkedbags = 0;

//Program Control variables
string programKey = "";
bool Quit = false, programSelectError = false, endProgram = false, saveData = false, resetData = false, dataReset = false;
bool bookReservation = false, saveReservation = false, seatprefLoop = false;
bool reservations_available = true, reserve_e = true, reserve_fc = true;
int programSelect = 0;

//Data Arrays
string[] customer_name_fc = new string[4]; string[] customer_name_e = new string[12];
string[] customer_address_fc = new string[4]; string[] customer_address_e = new string[12];
double[] customer_miles_fc = new double[4]; double[] customer_miles_e = new double[12];
int[] reservation_id_fc = new int[4]; int[] reservation_id_e = new int[12];
int[] num_checkedbags_fc = new int[4]; int[] num_checkedbags_e = new int[12];
bool[] program = new bool[4] { true, false, false, false };
bool[] seatAvailable_fc = new bool[4] { true, true, true, true };
bool[] seatAvailable_e = new bool[12] { true, true, true, true, true, true, true, true, true, true, true, true };

//Price Variables //Don’t Change for now, could have integrated them into the Settings and had a Separate Secret Menu for that.
const double economyPrice = 350, firstclassPrice = 500, checkedbags_cost = 25, miles_deduction = .8;

//Indexes
int customer_index, i = 0, index_e = 0, index_fc = 0;

//Keyboard Listener
ConsoleKeyInfo kb;

//Load Saved Files in the Arrays
try
{
//Loads economy array from file
FileStream fs_e = new FileStream(path + path_e, FileMode.Open);
StreamReader sr_e = new StreamReader(fs_e);
customer_index = 0;

while (sr_e.Peek() != -1)
{
if (customer_index < customer_name_e.Length)
{
reservation_id_e[customer_index] = Convert.ToInt32(sr_e.ReadLine());
customer_name_e[customer_index] = sr_e.ReadLine();
customer_address_e[customer_index] = sr_e.ReadLine();
seatAvailable_e[customer_index] = Convert.ToBoolean(sr_e.ReadLine());
num_checkedbags_e[customer_index] = Convert.ToInt32(sr_e.ReadLine());
customer_miles_e[customer_index] = Convert.ToDouble(sr_e.ReadLine());
sr_e.ReadLine();
customer_index++;
}
else
{
Console.WriteLine("Error! Too many Customers in the Data File");
Console.WriteLine("Only the 1st 12 Ecoomy Customers will be Loaded");
break;
}
}
fs_e.Close();
}
catch (IOException)
{
Console.WriteLine("No Economy Data Found, A New File has been Created");
Console.WriteLine("If this is an Error, Please Contact Technical Support");
Console.WriteLine(""); Console.WriteLine("Press Any Key to Continue");
Console.ReadKey();
}
catch (FormatException)
{

}

Console.WriteLine("");

try
{
//loads economy array from file
FileStream fs_fc = new FileStream(path + path_fc, FileMode.Open);
StreamReader sr_fc = new StreamReader(fs_fc);
customer_index = 0;

while (sr_fc.Peek() != -1)
{
if (customer_index < customer_name_e.Length)
{
reservation_id_fc[customer_index] = Convert.ToInt32(sr_fc.ReadLine());
customer_name_fc[customer_index] = sr_fc.ReadLine();
customer_address_fc[customer_index] = sr_fc.ReadLine();
seatAvailable_fc[customer_index] = Convert.ToBoolean(sr_fc.ReadLine());
num_checkedbags_fc[customer_index] = Convert.ToInt32(sr_fc.ReadLine());
customer_miles_fc[customer_index] = Convert.ToDouble(sr_fc.ReadLine());
sr_fc.ReadLine();
customer_index++;
}
else
{
Console.WriteLine("Error! Too many Customers in the Data File");
Console.WriteLine("Only the 1st 12 Ecoomy Customers will be Loaded");
break;
}
}
fs_fc.Close();
}
catch (IOException)
{
Console.WriteLine("No First Class Data Found, A New File will be Created");
Console.WriteLine("If this is an Error, Please Contact Technical Support");
Console.WriteLine(""); Console.WriteLine("Press Any Key to Continue");
Console.ReadKey();
}
catch (FormatException)
{

}

try
{
//Loads setttings from file
FileStream fs = new FileStream(path + path_s, FileMode.Open);
StreamReader sr = new StreamReader(fs);

while (sr.Peek() != -1)
{
reserve_fc = Convert.ToBoolean(sr.ReadLine());
reserve_e = Convert.ToBoolean(sr.ReadLine());
reservations_available = Convert.ToBoolean(sr.ReadLine());
}
fs.Close();
}
catch (IOException)
{
Console.WriteLine("Application Settings not found, Default Settings have been Applied");
Console.WriteLine(""); Console.WriteLine("Press Any Key to Continue");
Console.ReadKey();
}

customer_index = 0; //reset customer_index

while (!Quit) //Main Program Loop
{
while (program[0]) //Main Menu
{
Console.Clear(); Console.Title = "Flight Reservation";
Console.WriteLine(" Please Select from the Following Options:"); Console.WriteLine("");
Console.WriteLine(" 1. Book a Reservation");
Console.WriteLine(" 2. Lookup a Reservation");
Console.WriteLine(" 3. Cancel a Reservation"); Console.WriteLine("");
Console.WriteLine(" Q. Quit");

if (programSelectError) //Invalid Selection
{
Console.WriteLine("");
Console.WriteLine(" That is not a Valid Choice, Enter # 1-3 or Q to Quit");
programSelectError = false;
}

if (dataReset) //Data Reset Successful
{
Console.WriteLine(""); Console.WriteLine(" Data Reset");
dataReset = false;
}

Console.WriteLine(""); Console.Write(" Enter your Selection: ");

kb = Console.ReadKey(); //Listens for Key
programKey = kb.KeyChar.ToString();
if (kb.Key == ConsoleKey.Q) //Quits Program
{
Console.Clear(); Console.Title = "Quit?";
Console.Write(" Are you sure you want to Quit? (y/n): ");
kb = Console.ReadKey(); //Listens for Key
if (kb.Key == ConsoleKey.N) // N Returns to Main Menu
{
programKey = "9"; /*Returns you to the Main Menu*/
}
else if (kb.Key == ConsoleKey.Y) //Quits Main Program
{
program[0] = false; saveData = true; Quit = true;
}
else //Still Returns to Main Menu
{
Console.WriteLine("");
Console.WriteLine(" You didn’t hit Y or N."); Console.WriteLine(" I’m going to assume you said No.");
Console.WriteLine(" Press Any Key to Return to the Main Menu"); Console.ReadKey();
programKey = "9"; /*Returns you to the Main Menu*/
}
}
if (kb.Key == ConsoleKey.R) //Reset Prompt
{
string resetPWD_input; string resetPWD = "snapon21"; //set reset password here
Console.WriteLine(""); Console.Write(" Reset Password: ");
resetPWD_input = Console.ReadLine();
if (resetPWD_input == resetPWD)
{
resetData = true; saveData = true; program[0] = false;
break;
}
else
{
programKey = "9";
}
}

Int32.TryParse(programKey, out programSelect);
switch (programSelect) //Program Selection
{
case 1: program[0] = false; program[1] = true; break;
case 2: program[0] = false; program[2] = true; break;
case 3: program[0] = false; program[3] = true; break;
case 9: break;
default: programSelectError = true; break;
}
}

while (program[1]) //Book a Reservation
{
Console.Clear(); Console.Title = "Book a Reservation"; //Change Program Title

//Checks to see if Economy Seats are Available
for (i = 0; i < (seatAvailable_e.Length + 1); i++)
{
if (i == seatAvailable_e.Length) //If no seats available return false
{
reserve_e = false; break;
}
if (seatAvailable_e[i] == true)
{
reserve_e = true; bookReservation = true;
index_e = i; break;
}
}

//Checks to see if First Class Seats are Available
for (i = 0; i < (seatAvailable_fc.Length + 1); i++)
{
if (i == seatAvailable_fc.Length) //If no seats available return false
{
reserve_fc = false; break;
}

if (seatAvailable_fc[i] == true)
{
reserve_fc = true; bookReservation = true;
index_fc = i; break;
}
}

//If no Seats are Available at all
if (reserve_e == false && reserve_fc == false)
reservations_available = false;

//No Reservations Available
if (reservations_available == false)
{
Console.WriteLine("No Reservations Available");
Console.WriteLine("Press Any Key to Return to the Main Menu");
Console.ReadKey(); programKey = "9";
program[1] = false; saveData = true; break;
}

//While Seats are Available
//Main Input Loop
while (bookReservation)
{
Console.Write("Customers Name: "); temp_customer_name = Console.ReadLine();
Console.Write("Customers Address: "); temp_customer_address = Console.ReadLine();

bool seatAvailbiltyCheck = true;

//Let User know if a class is full and asks if the other class is ok
while (seatAvailbiltyCheck)
{
if (reserve_e == false && reserve_fc == true)
{
Console.WriteLine("Economy not Available");
Console.Write("Is First Class ok? (y/n): ");
kb = Console.ReadKey(); //Listens for Key
Console.WriteLine("");

if (kb.Key == ConsoleKey.Y)
{
temp_seatpref = "first class"; seatAvailbiltyCheck = false; seatprefLoop = true;
}
else if (kb.Key == ConsoleKey.N)
{
Console.WriteLine("");
Console.WriteLine("Reservaton Not Saved");
Console.Write("Would you like to Enter another Reservation? (y/n): ");
program[1] = false; saveData = true; endProgram = true;
bookReservation = false; seatAvailbiltyCheck = false;
break;
}
else
{
Console.WriteLine("");
Console.WriteLine("You didn’t hit Y or N."); Console.WriteLine("I’m going to assume you said No.");
Console.WriteLine("Reservaton Not Saved");
Console.Write("Would you like to Enter another Reservation? (y/n): ");
program[1] = false; saveData = true; endProgram = true;
bookReservation = false; seatAvailbiltyCheck = false;
break;
}
Console.WriteLine("Seat Preference: First Class");
}
if (reserve_fc == false && reserve_e == true)
{
Console.WriteLine("First Class not Available");
Console.Write("Is Economy ok? (y/n): ");
kb = Console.ReadKey(); //Listens for Key
Console.WriteLine("");

if (kb.Key == ConsoleKey.Y)
{
temp_seatpref = "economy"; seatAvailbiltyCheck = false; seatprefLoop = true;
}
else if (kb.Key == ConsoleKey.N)
{
Console.WriteLine("");
Console.WriteLine("Reservaton Not Saved");
Console.Write("Would you like to Enter another Reservation? (y/n): ");
program[1] = false; saveData = true; endProgram = true;
bookReservation = false; seatAvailbiltyCheck = false;
break;
}
else
{
Console.WriteLine("");
Console.WriteLine("You didn’t hit Y or N."); Console.WriteLine("I’m going to assume you said No.");
Console.WriteLine("Reservaton Not Saved");
Console.Write("Would you like to Enter another Reservation? (y/n): ");
program[1] = false; saveData = true; endProgram = true;
bookReservation = false; seatAvailbiltyCheck = false;
break;
}
Console.WriteLine("Seat Preference: Economy");
}
if (reserve_e == true && reserve_fc == true)
{
Console.Write("Seat Preference (Economy/First Class): ");
temp_seatpref = Console.ReadLine(); temp_seatpref = temp_seatpref.ToLower();
seatprefLoop = true; seatAvailbiltyCheck = false;
}
}

while (seatprefLoop)
{
if (temp_seatpref == "economy")
{
customer_index = index_e; seatprefLoop = false;
}
if (temp_seatpref == "first class")
{
customer_index = index_fc; seatprefLoop = false;
}
if (temp_seatpref != "economy" && temp_seatpref != "first class")
{
Console.WriteLine("That is not a Valid Choice!");
Console.Write("Please Enter ‘economy’ or ‘first class’: ");
temp_seatpref = Console.ReadLine();
}
}
if (bookReservation == true)
{
Console.Write("Enter Number of Checked Bags: "); Int32.TryParse(Console.ReadLine(), out temp_checkedbags);
if (temp_checkedbags < 0) temp_checkedbags = 0; //To ensure negative numbers are not entered.
Console.Write("Enter Flyer Miles: "); Double.TryParse(Console.ReadLine(), out temp_miles);
saveReservation = true; bookReservation = false;
}
}

//Saves Data to Array & Calculate Cost & Write Ticket

while (saveReservation)
{
if (temp_seatpref == "first class")
{
//Save Data to Array
reservation_id_fc[customer_index] = customer_index + 101;
customer_name_fc[customer_index] = temp_customer_name;
customer_address_fc[customer_index] = temp_customer_address;
seatAvailable_fc[customer_index] = false;
num_checkedbags_fc[customer_index] = temp_checkedbags;
customer_miles_fc[customer_index] = temp_miles;

//Calculate Cost
double totalcost;
if (customer_miles_fc[customer_index] > 4000)
totalcost = (firstclassPrice * miles_deduction) + (num_checkedbags_fc[customer_index] * checkedbags_cost);
else
totalcost = firstclassPrice + (num_checkedbags_fc[customer_index] * checkedbags_cost);

//Write Ticket Information
Console.WriteLine("");
Console.WriteLine("Reservation ID: {0}", reservation_id_fc[customer_index]);
Console.WriteLine("Customers Name: {0}", customer_name_fc[customer_index]);
Console.WriteLine("Customers Address: {0}", customer_address_fc[customer_index]);
Console.WriteLine("Seat Preference: First Class");
Console.WriteLine("Number of Checked Bags: {0}", num_checkedbags_fc[customer_index]);
Console.WriteLine("Flyer Miles: {0}", customer_miles_fc[customer_index]);

if (customer_miles_fc[customer_index] > 4000)
Console.WriteLine("Qualifies for Frequent Flyer Discount");

Console.WriteLine(""); Console.WriteLine("Total: {0:C}", totalcost);

}
if (temp_seatpref == "economy")
{
//Save Data to Array
reservation_id_e[customer_index] = customer_index + 201;
customer_name_e[customer_index] = temp_customer_name;
customer_address_e[customer_index] = temp_customer_address;
seatAvailable_e[customer_index] = false;
num_checkedbags_e[customer_index] = temp_checkedbags;
customer_miles_e[customer_index] = temp_miles;

//Calculate Cost
double totalcost;
if (customer_miles_e[customer_index] > 4000)
totalcost = (economyPrice * miles_deduction) + (num_checkedbags_e[customer_index] * checkedbags_cost);
else
totalcost = economyPrice + (num_checkedbags_e[customer_index] * checkedbags_cost);

//Write Ticket Information
Console.WriteLine("");
Console.WriteLine("Reservation ID: {0}", reservation_id_e[customer_index]);
Console.WriteLine("Customers Name: {0}", customer_name_e[customer_index]);
Console.WriteLine("Customers Address: {0}", customer_address_e[customer_index]);
Console.WriteLine("Seat Preference: Economy");
Console.WriteLine("Number of Checked Bags: {0}", num_checkedbags_e[customer_index]);
Console.WriteLine("Flyer Miles: {0}", customer_miles_e[customer_index]);

if (customer_miles_e[customer_index] > 4000)
Console.WriteLine("Qualifies for Frequent Flyer Discount");

Console.WriteLine(""); Console.WriteLine("Total: {0:C}", totalcost);
}
saveReservation = false;
Console.WriteLine("");
Console.Write("Would you like to Enter another Reservation? (y/n): ");
program[1] = false; saveData = true; endProgram = true;
}
}

while (program[2]) //Lookup a Reservation
{
Console.Clear(); Console.Title = "Lookup a Reservation"; //Change Program Title
Console.Write("Enter the Reservation Number: ");
Int32.TryParse(Console.ReadLine(), out int temp_id); Console.WriteLine("");
if (temp_id > 100 && temp_id < (customer_name_fc.Length + 101))
{
customer_index = temp_id – 101;

if (customer_name_fc[customer_index] == "")
{
Console.WriteLine("Invalid Reservation");
}
else
{
//Calculate Cost
double totalcost;
if (customer_miles_fc[customer_index] > 4000)
totalcost = (firstclassPrice * miles_deduction) + (num_checkedbags_fc[customer_index] * checkedbags_cost);
else
totalcost = firstclassPrice + (num_checkedbags_fc[customer_index] * checkedbags_cost);

//Write Ticket Information
Console.WriteLine("");
Console.WriteLine("ID: {0} | Name: {1}", reservation_id_fc[customer_index], customer_name_fc[customer_index]);
Console.WriteLine("Address: {0}", customer_address_fc[customer_index]);
Console.WriteLine("Seat Preference: First Class");
Console.WriteLine("Number of Checked Bags: {0}", num_checkedbags_fc[customer_index]);
Console.WriteLine("Flyer Miles: {0}", customer_miles_fc[customer_index]);

if (customer_miles_fc[customer_index] > 4000)
Console.WriteLine("Qualifies for Frequent Flyer Discount");

Console.WriteLine(""); Console.WriteLine("Total: {0:C}", totalcost);
}
}
else if (temp_id > 200 && temp_id < (customer_name_e.Length + 201))
{
customer_index = temp_id – 201;

if (customer_name_e[customer_index] == "")
{
Console.WriteLine("Invalid Reservation");
}
else
{
//Calculate Cost
double totalcost;
if (customer_miles_e[customer_index] > 4000)
totalcost = (economyPrice * miles_deduction) + (num_checkedbags_e[customer_index] * checkedbags_cost);
else
totalcost = economyPrice + (num_checkedbags_e[customer_index] * checkedbags_cost);

//Write Ticket Information
Console.WriteLine("");
Console.WriteLine("ID: {0} | Name: {1}", reservation_id_e[customer_index], customer_name_e[customer_index]);
Console.WriteLine("Address: {0}", customer_address_e[customer_index]);
Console.WriteLine("Seat Preference: Economy");
Console.WriteLine("Number of Checked Bags: {0}", num_checkedbags_e[customer_index]);
Console.WriteLine("Flyer Miles: {0}", customer_miles_e[customer_index]);

if (customer_miles_e[customer_index] > 4000)
Console.WriteLine("Qualifies for Frequent Flyer Discount");

Console.WriteLine(""); Console.WriteLine("Total: {0:C}", totalcost);
}
}
else
{
Console.WriteLine("Invalid Reservation Number");
}

Console.WriteLine("");
Console.Write("Would you like to Lookup another Reservation? (y/n): ");
program[2] = false; saveData = true; endProgram = true;
}

while (program[3]) //Cancel a Reservation
{
Console.Clear(); Console.Title = "Cancel a Reservation"; //Change Program Title
Console.Write("Enter the Reservation ID: ");
Int32.TryParse(Console.ReadLine(), out int temp_id);
Console.WriteLine("");

//If ID is First Class
if (temp_id > 100 && temp_id < (reservation_id_e.Length + 101))
{
customer_index = temp_id – 101;
if (customer_name_fc[customer_index] == "")
{
Console.WriteLine("Invalid Reservation");
}
else
{
//Calculate Cost
double totalcost;
if (customer_miles_fc[customer_index] > 4000)
totalcost = (firstclassPrice * miles_deduction) + (num_checkedbags_fc[customer_index] * checkedbags_cost);
else
totalcost = firstclassPrice + (num_checkedbags_fc[customer_index] * checkedbags_cost);

Console.WriteLine("ID: {0} | Name: {1}", reservation_id_fc[customer_index], customer_name_fc[customer_index]);
Console.WriteLine("Address: {0}", customer_address_fc[customer_index]);
Console.WriteLine("Seat Preference: First Class");
Console.WriteLine("Number of Checked Bags: {0}", num_checkedbags_fc[customer_index]);
Console.WriteLine("Flyer Miles: {0}", customer_miles_fc[customer_index]);
Console.WriteLine(""); Console.WriteLine("Refund Amount: {0:C}", totalcost);
Console.WriteLine(""); Console.Write("Cancel this Reservation? (y/n): ");

kb = Console.ReadKey(); //Listens for Key
Console.WriteLine("");

if (kb.Key == ConsoleKey.Y)
{
reservation_id_fc[customer_index] = 0;
customer_name_fc[customer_index] = "";
customer_address_fc[customer_index] = "";
seatAvailable_fc[customer_index] = true;
reserve_fc = true; reservations_available = true;
num_checkedbags_fc[customer_index] = 0;
customer_miles_fc[customer_index] = 0;

Console.WriteLine("");
Console.WriteLine("Reservation {0} has been Canceled", temp_id);
}

else if (kb.Key == ConsoleKey.N)
{
Console.WriteLine("");
Console.WriteLine("No Changes have been made");
}

else
{
Console.WriteLine("");
Console.WriteLine("You didn’t hit Y or N."); Console.WriteLine("I’m going to assume you said No.");
Console.WriteLine("");
Console.WriteLine("No Changes have been made");
}
}
}
//If ID is Economy
if (temp_id > 200 && temp_id < (reservation_id_e.Length + 201))
{
customer_index = temp_id – 201;

if (customer_name_e[customer_index] == "")
{
Console.WriteLine("Invalid Reservation");
}
else
{
//Calculate Cost
double totalcost;
if (customer_miles_e[customer_index] > 4000)
totalcost = (economyPrice * miles_deduction) + (num_checkedbags_e[customer_index] * checkedbags_cost);
else
totalcost = economyPrice + (num_checkedbags_e[customer_index] * checkedbags_cost);

Console.WriteLine("ID: {0} | Name: {1}", reservation_id_e[customer_index], customer_name_e[customer_index]);
Console.WriteLine("Address: {0}", customer_address_e[customer_index]);
Console.WriteLine("Seat Preference: Economy");
Console.WriteLine("Number of Checked Bags: {0}", num_checkedbags_e[customer_index]);
Console.WriteLine("Flyer Miles: {0}", customer_miles_e[customer_index]);
Console.WriteLine(""); Console.WriteLine("Refund Amount: {0:C}", totalcost);
Console.WriteLine(""); Console.Write("Cancel this Reservation? (y/n): ");

kb = Console.ReadKey(); //Listens for Key
Console.WriteLine("");

if (kb.Key == ConsoleKey.Y)
{
reservation_id_e[customer_index] = 0;
customer_name_e[customer_index] = "";
customer_address_e[customer_index] = "";
seatAvailable_e[customer_index] = true;
reserve_e = true; reservations_available = true;
num_checkedbags_e[customer_index] = 0;
customer_miles_e[customer_index] = 0;

Console.WriteLine("");
Console.WriteLine("Reservation {0} has been Canceled", temp_id);
}
else if (kb.Key == ConsoleKey.N)
{
Console.WriteLine("");
Console.WriteLine("No Changes have been made");
}
else
{
Console.WriteLine("");
Console.WriteLine("You didn’t hit Y or N."); Console.WriteLine("I’m going to assume you said No.");
Console.WriteLine("");
Console.WriteLine("No Changes have been made");
}
}
}
Console.WriteLine("");
Console.Write("Would you like to Cancel another Reservation? (y/n): ");
program[3] = false; saveData = true; endProgram = true;
}

while (saveData)
{
//Reset Data Files
if (resetData == true)
{
customer_name_fc = new string[4]; customer_name_e = new string[12];
customer_address_fc = new string[4]; customer_address_e = new string[12];
customer_miles_fc = new double[4]; customer_miles_e = new double[12];
reservation_id_fc = new int[4]; reservation_id_e = new int[12];
num_checkedbags_fc = new int[4]; num_checkedbags_e = new int[12];
seatAvailable_fc = new bool[4] { true, true, true, true };
seatAvailable_e = new bool[12] { true, true, true, true, true, true, true, true, true, true, true, true };
reservations_available = true; reserve_e = true; reserve_fc = true;

resetData = false; program[0] = true;
dataReset = true;
}

//Write First Class Data
try
{
StreamWriter sw_fc = new StreamWriter(path + path_fc);
for (customer_index = 0; customer_index < customer_name_fc.Length; customer_index++)
{
sw_fc.WriteLine(reservation_id_fc[customer_index]);
sw_fc.WriteLine(customer_name_fc[customer_index]);
sw_fc.WriteLine(customer_address_fc[customer_index]);
sw_fc.WriteLine(seatAvailable_fc[customer_index]);
sw_fc.WriteLine(num_checkedbags_fc[customer_index]);
sw_fc.WriteLine(customer_miles_fc[customer_index]);
sw_fc.WriteLine("");
}
sw_fc.Close();
}
catch (IOException)
{
Console.WriteLine("");
Console.WriteLine("Could not Save First Class Data!");
Console.WriteLine("Refer to Documentation for Support");
}

try
{
//Write Economy Data
StreamWriter sw_e = new StreamWriter(path + path_e);
for (customer_index = 0; customer_index < customer_name_e.Length; customer_index++)
{
sw_e.WriteLine(reservation_id_e[customer_index]);
sw_e.WriteLine(customer_name_e[customer_index]);
sw_e.WriteLine(customer_address_e[customer_index]);
sw_e.WriteLine(seatAvailable_e[customer_index]);
sw_e.WriteLine(num_checkedbags_e[customer_index]);
sw_e.WriteLine(customer_miles_e[customer_index]);
sw_e.WriteLine("");
}
sw_e.Close();
}
catch (IOException)
{
Console.WriteLine("");
Console.WriteLine("Could not Save Economy Data!");
Console.WriteLine("Refer to Documentation for Support");
}
try
{
//Write Settings
StreamWriter sw = new StreamWriter(path + path_s);

sw.WriteLine(reserve_fc);
sw.WriteLine(reserve_e);
sw.WriteLine(reservations_available);
sw.Close();
}
catch (IOException)
{
Console.WriteLine("");
Console.WriteLine("Could not Save Settings Data!");
Console.WriteLine("Refer to Documentation for Support");
}

saveData = false;

//End Program
if (endProgram == true)
{
kb = Console.ReadKey(); //Listens for Key
if (kb.Key == ConsoleKey.N) // N Returns to Main Menu
{
program[0] = true; /*Returns you to the Main Menu*/
}
else if (kb.Key == ConsoleKey.Y) // Y Goes back to previous Program
{
program[programSelect] = true; /*Goes back to previous Program*/
}
else //Still Returns to Main Menu
{
Console.WriteLine("");
Console.WriteLine("You didn’t hit Y or N."); Console.WriteLine("I’m going to assume you said No.");
Console.WriteLine("Press Any Key to Return to the Main Menu"); Console.ReadKey();
program[0] = true; /*Returns you to the Main Menu*/
}
endProgram = false; saveData = false;
}

//Program Key 9 Exception
if (programKey == "9")
{
saveData = false; program[0] = true;
}
}
}
}
}
}
[/code]