Code
Code
#include <string>
#include <iomanip>
#include <conio.h>
#include <fstream>
using namespace std;
string pilots[MAX_PILOTS];
string pilot_license_numbers[MAX_PILOTS];
string airHostesses[MAX_AIR_HOSTESSES];
string air_hostess_employee_ids[MAX_AIR_HOSTESSES];
string duty_start_times[MAX_AIR_HOSTESSES];
string duty_end_times[MAX_AIR_HOSTESSES];
string weather_dates[MAX_WEATHER];
int weather_windSpeed[MAX_WEATHER];
int weather_visibility[MAX_WEATHER];
string flight_names[MAX_FLIGHTS];
string flight_times[MAX_FLIGHTS];
string customer_names[MAX_FLIGHTS][MAX_CUSTOMERS_PER_FLIGHT];
string customer_phone[MAX_FLIGHTS][MAX_CUSTOMERS_PER_FLIGHT]; // New phone array
string customer_email[MAX_FLIGHTS][MAX_CUSTOMERS_PER_FLIGHT];
string customer_passport_number[MAX_FLIGHTS][MAX_CUSTOMERS_PER_FLIGHT];
int customer_count[MAX_FLIGHTS] = {0};
int pilot_count = 0, air_hostess_count = 0, flight_count = 0, weather_count = 0;
void mainmenu();
void addPilot(string pilots[], string pilot_license_numbers[], int &pilot_count);
void deletePilot(string pilots[], string pilot_license_numbers[], int
&pilot_count);
void updatePilot(string pilots[], string pilot_license_numbers[], int pilot_count);
void listPilots(const string pilots[], const string pilot_license_numbers[], int
pilot_count);
void mainmenu()
{
do{
system("cls");
cout << "
-----------------------------------------------------------------------------------
----------------------------" << endl;
cout << "
___________________________________________________________________________________
________________________" << endl;
cout << " |
|" << endl;
cout << " | __ |__ _______ ___ ___
__ ___________ _______ |__ ___ ___ |" << endl;
cout << " | /\"\"\\ |\" \\ /\" \\
|\" \\ /\" | /\"\"\\(\" _ \")/\" \\ |\" \\ |\" \\/\" |
|" << endl;
cout << " | / \\ || | |: | \\ \\ // |
/ \\)__/ \\\\__/|: | || | \\ \\ / |" << endl;
cout << " | /' /\\ \\ |: | |_____/ ) /\\\\ \\ /. |
/' /\\ \\ \\\\_ / |_____/ ) |: | \\\\ \\/ |" << endl;
cout << " | // __' \\ |. | // / |: \\.
| // __' \\ |. | // / |. | /\\. \\ |" << endl;
cout << " | / / \\\\ \\ /\\ |\\ |: __ \\ |. \\ /:
| / / \\\\ \\\\: | |: __ \\ /\\ |\\ / \\ \\ |" << endl;
cout << " | (___/ \\___)(__\\_|_)|__| \\___) |___|\\__/|___|
(___/ \\___)\\__| |__| \\___)(__\\_|_)|___/\\___| |" << endl;
cout << " |
___________________________________________________________________________________
_______________________|" << endl;
cout << "
-----------------------------------------------------------------------------------
----------------------------" << endl;
cout << " " << endl;
cout <<
" ,------------------------------------------------------------------------------
------------------------------------," << endl;
cout << " | 1. Pilot Menu
2. Air Hostess Menu |" << endl;
cout << " | 3. Flight Menu
4. Weather Menu |" << endl;
cout << " | 5. Exit
|" << endl;
cout << " \\
___________________________________________________________________________________
________________________________/" << endl;
cout << " ->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->-
>->->->->->->->->->->->->->->->->->->->->->->->->->->->-" << endl;
cout << "[Enter your choice] ";
cin >> mainChoice;
} while(!isValidInput);
}
if (pilot_count == 0)
{
cout << "No pilots to display.\n";
getch();
return;
}
cout << "\n>>>>>>>>[ LIST PILOT RECORD ]<<<<<<<<\n";
cout << left << setw(20) << "Index" << setw(20) << "Name" << setw(20) <<
"License" << endl;
for (int i = 0; i < pilot_count; i++)
{
cout << left << setw(20) << i << setw(20) << pilots[i] << setw(20) <<
pilot_license_numbers[i] << endl;
}
getch();
}
// airhostess menu functions
void addAirHostess(string airHostesses[], string duty_start_times[], string
duty_end_times[], string air_hostess_employee_ids[], int &air_hostess_count)
{
cout << "\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>[ ADD Air
Hostesses ]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n";
if (air_hostess_count < MAX_AIR_HOSTESSES)
{
do
{
cout << "Enter air hostess name: ";
getline(cin, airHostesses[air_hostess_count]);
{
if (airHostesses[air_hostess_count].empty())
{
cout << "Air Hostesses name can't be empty.Try again.";
}
if (noDigits(airHostesses[air_hostess_count]))
{
cout << "Invalid input! Name should not contain numbers." <<
endl;
}
}
} while (airHostesses[air_hostess_count].empty() ||
(noDigits(airHostesses[air_hostess_count])));
do
{
cout << "Enter air hostess employee ID: ";
getline(cin, air_hostess_employee_ids[air_hostess_count]);
{
if (air_hostess_employee_ids[air_hostess_count].empty())
{
cout << "Air Hostesses employee id can't be empty.Try again.";
}
if (!isNumeric(air_hostess_employee_ids[air_hostess_count]))
{
cout << "Invalid employee id! \n";
}
}
} while (air_hostess_employee_ids[air_hostess_count].empty() || !
isNumeric(air_hostess_employee_ids[air_hostess_count]));
do
{
cout << "Enter duty start time: ";
cin >> duty_start_times[air_hostess_count];
if (!isValidTime(duty_start_times[air_hostess_count]))
{
cout << "Invalid flight time. Please enter in HH:MM format (00:00 -
23:59).\n";
}
} while (!isValidTime(duty_start_times[air_hostess_count]));
do
{
cout << "Enter duty end time: ";
cin >> duty_end_times[air_hostess_count];
if (!isValidTime(duty_end_times[air_hostess_count]))
{
cout << "Invalid flight time. Please enter in HH:MM format (00:00 -
23:59).\n";
}
} while (!isValidTime(duty_end_times[air_hostess_count]));
cin.ignore();
air_hostess_count++;
saveAirHostessesToFile(airHostesses, duty_start_times, duty_end_times,
air_hostess_employee_ids, air_hostess_count);
cout << "Air hostess added successfully.\n";
}
else
{
cout << "Maximum number of air hostess limit reached.\n";
}
getch();
}
void deleteAirHostess(string airHostesses[], string duty_start_times[], string
duty_end_times[], string air_hostess_employee_ids[], int &air_hostess_count)
{
cout << "\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>[ DELETE Air
Hostesses ]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n";
if (air_hostess_count == 0)
{
cout << "No air hostesses to delete.\n";
getch();
return;
}
{
cout << "No air hostesses to update.\n";
getch();
return;
}
// weather functions
void addWeatherCondition(string weather_dates[], int weather_windSpeed[], int
weather_visibility[], int &weather_count)
{
cout << "\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>[ ADD
WEATHER ]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n";
if (weather_count < MAX_WEATHER)
{
do
{
cout << "Enter date (e.g. DD/MM/YYYY): ";
getline(cin, weather_dates[weather_count]);
} while (!isValidDate(weather_dates[weather_count]));
if (weather_count < MAX_WEATHER)
{
cout << "Enter wind speed (in km/h): ";
cin >> weather_windSpeed[weather_count];
cout << "Enter visibility (in meters): ";
cin >> weather_visibility[weather_count];
cin.ignore();
weather_count++;
saveWeatherData(weather_dates, weather_windSpeed, weather_visibility,
weather_count);
cout << "Weather condition added successfully.\n";
}
}
else
{
cout << "Maximum weather conditions reached.\n";
}
}
int index;
cout << "Enter the index of the weather condition to delete: ";
cin >> index;
cin.ignore();
int index;
cout << "Enter the index of the weather condition to update: ";
cin >> index;
cin.ignore();
if (index >= 0 && index < weather_count)
{
do
{
cout << "Enter new weather date (DD/MM/YYYY): ";
cin >> weather_dates[index];
} while (!isValidDate(weather_dates[index]));
cout << "Enter new wind speed: ";
cin >> weather_windSpeed[index];
cout << "Enter new visibility: ";
cin >> weather_visibility[index];
saveWeatherData(weather_dates, weather_windSpeed, weather_visibility,
weather_count);
cout << "Weather condition updated successfully.\n";
}
else
{
cout << "Invalid index.\n";
}
}
string dateToCheck;
do
{
cout << "Enter the date you want to check (e.g. (DD/MM/YYYY)): ";
getline(cin, dateToCheck);
} while (!isValidDate(dateToCheck));
bool found = false;
for (int i = 0; i < weather_count; i++)
{
if (weather_dates[i] == dateToCheck)
{
cout << "\n--- Weather on " << weather_dates[i] << " ---\n";
cout << "Wind Speed: " << weather_windSpeed[i] << " km/h\n";
cout << "Visibility: " << weather_visibility[i] << " meters\n";
found = true;
break;
}
}
if (!found)
{
cout << "No weather data found for the date: " << dateToCheck << endl;
}
}
void listWeatherConditions(const string weather_dates[], const string
weather_windSpeed[], const string weather_visibility[], int weather_count)
{
if (weather_count == 0)
{
cout << "No weather conditions to display.\n";
return;
}
cout << "\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>[ LIST
WEATHER ]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n";
cout << left << setw(15) << "Date"
<< setw(20) << "Wind Speed (km/h)"
<< setw(20) << "Visibility (meters)" << endl;
for (int i = 0; i < weather_count; i++)
{
cout << left << setw(15) << weather_dates[i]
<< setw(20) << weather_windSpeed[i]
<< setw(20) << weather_visibility[i] << endl;
}
getch();
}
// Flight Record functions
void addFlight(string flight_names[], string flight_times[], int &flight_count)
{
cout << "\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>[ ADD FLIGHT
RECORD ]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n";
if (flight_count < MAX_FLIGHTS)
{
do
{
cout << "Enter flight name: ";
getline(cin, flight_names[flight_count]);
{
if (flight_names[flight_count].empty())
{
cout << "Flight Name can't be empty." << endl;
}
}
} while (flight_names[flight_count].empty() );
do
{
cout << "Enter flight time(e.g. HH:MM): ";
getline(cin, flight_times[flight_count]);
{
if (!isValidTime(flight_times[flight_count]))
{
cout << "Invalid flight time. Please enter in HH:MM format
(00:00 - 23:59).\n";
}
}
} while (!isValidTime(flight_times[flight_count]));
flight_count++;
{
ofstream file("flights.txt", ios::app);
if (file)
{
file << flight_names[flight_count - 1] << "," <<
flight_times[flight_count - 1] << endl;
}
file.close();
}
cout << "Flight added successfully.\n";
}
else
{
cout << "Maximum flight limit reached.\n";
}
}
int index;
cout << "Enter the index of the flight to delete: ";
cin >> index;
cin.ignore();
if (index >= 0 && index < MAX_FLIGHTS)
{
for (int i = index; i < flight_count - 1; i++)
{
flight_names[i] = flight_names[i + 1];
flight_times[i] = flight_times[i + 1];
}
flight_count--;
ofstream file("flights.txt");
if (file)
{
for (int i = 0; i < flight_count; i++)
{
file << flight_names[i] << "," << flight_times[i] << endl;
}
file.close();
customer_count[flightIndex]++;
cout << "Customer added to flight " << flight_names[flightIndex] << ".\n";
saveCustomerDataToFile(flightIndex, customer_count[flightIndex],
customer_names, customer_phone, customer_email);
}
else
{
cout << "This flight is fully booked.\n";
}
}
customerIndex--;
// MAIN FUNCTION
int main()
{
do
{
mainmenu();
if (mainChoice == 1)
{
int pilotChoice;
string pilots[MAX_PILOTS];
string pilot_license_numbers[MAX_PILOTS];
do
{
system("cls");
cout << " _______ |__ ___ ______
___________ ___ ___ _______ _____ ___ ____ ____ \n";
cout << " | __ \"\\ |\" \\ |\" | / \" \\
(\" _ \") |\" \\ /\" | /\" \"| (\\\" \\|\" \\ (\" _||_ \" |
\n";
cout << " (. |__) :) || | || | //
____ \\ )__/ \\\\__/ \\ \\ // |(: ______) |.\\\\ \\ | |
( ) : | \n";
cout << " |: ____/ |: | |: | / / ) :) \\\\_
/ /\\\\ \\/. | \\/ | |: \\. \\\\ | (: | | . ) \n";
cout << " (| / |. | \\ |___ (: (____/ // |.
| |: \\. | // ___)_ |. \\ \\. | \\\\ \\__/ // \n";
cout << " /|__/ \\ /\\ |\\ ( \\_|: \\ \\ /
\\: | |. \\ /: |(: \"| | \\ \\ | /\\\\ __ //\\ \n";
cout << " (_______) (__\\_|_) \\
_______) \\\"_____/ \\__| |___|\\__/|___| \\_______) \\___|\\
____\\) (__________) \n";
cout << "
\n";
cout << " " << endl;
cout <<
" ,------------------------------------------------------------------------------
------------------------------------," << endl;
cout << " | 1. Add Pilot
2. Delete Pilot |" << endl;
cout << " | 3. Update Pilot
4. List Pilot |" << endl;
cout << " | 5. Back to
Main Menu |" << endl;
cout << " \\
___________________________________________________________________________________
________________________________/" << endl;
cout << " ->->->->->->->->->->->->->->->->->->->->->->->->->->->->-
>->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->-" << endl;
do
{
cout << "[Enter your choice]:";
cin >> pilotChoice;
if (pilotChoice < 1 && pilotChoice > 5)
cout << "Please Enter a valid choice.";
} while (pilotChoice < 1 && pilotChoice > 5);
cin.ignore();
switch (pilotChoice)
{
case 1:
addPilot(pilots, pilot_license_numbers, pilot_count);
break;
case 2:
deletePilot(pilots, pilot_license_numbers, pilot_count);
break;
case 3:
updatePilot(pilots, pilot_license_numbers, pilot_count);
break;
case 4:
listPilots(pilots, pilot_license_numbers, pilot_count);
break;
case 5:
break;
default:
cout << "Invalid choice.\n";
}
} while (pilotChoice != 5);
}
else if (mainChoice == 2)
{
int hostessChoice;
do
{
system("cls");
cout << " __ |__ _______ __ __ ______
________ ___________ _______ ________ ________ ___ ___ _______
_____ ___ ____ ____ " << endl;
cout << " /\"\"\\ |\" \\ /\" \\ /\" |
| \"\\ / \" \\ /\" )(\"
_ \") /\" \"| /\" ) /\" ) |\" \\ /\" | /\" \"|
(\\\" \\|\" \\ (\" _||_ \" | " << endl;
cout << " / \\ || | |: |(: (__) :) //
____ \\ (: \\___/ )__/ \\\\__/ (: ______)(: \\___/ (: \\
___/ \\ \\ // |(: ______) |.\\\\ \\ | | ( ) | " << endl;
cout << " /' /\\ \\ |: | |
_____/ ) \\/ \\/ / / ) :) \\___ \\ \\\\_ / \\/ | \\
___ \\ \\___ \\ /\\\\ \\/. | \\/ | |: \\. \\\\ | | | | |
" << endl;
cout << " // __' \\ |. | // / // __ \\\\(:
(____/ // __/ \\\\ |. | // ___)_ __/ \\\\ __/ \\\\ |: \\.
| // ___)_ |. \\ \\. | | \\__/ | " << endl;
cout << " / / \\\\ \\ /\\ |\\ |: __ \\ |: ( ) |\\
/ /\" \\ :) \\: | (: \"| /\" \\ :) /\" \\ :) |. \\ /:
|(: \"| | \\ \\ | \\ / " << endl;
cout << "(___/ \\___)(__\\_|_) |__| \\___) \\__| |
__/ \\\"_____/ (_______/ \\__| \\_______)(_______/ (_______/ |
___|\\_/|___| \\_______) \\___|\\____\\| \\______/ " << endl;
cout << "
" << endl;
cout << " " << endl;
cout <<
" ,-------------------------------------------------------------------
-----------------------------------------------," << endl;
cout << " | 1. Add AirHostess
2. Delete AirHostess |" << endl;
cout << " | 3. Update AirHostess
4. List AirHostess |" << endl;
cout << " |
5. Back to Main Menu |" << endl;
cout << " \\
___________________________________________________________________________________
________________________________/" << endl;
cout << " ->->->->->->->->->->->->->->->->->->->->->->->->->->->->-
>->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->-
>->->->->->->->->->->->-" << endl;
do
{
cout << "[Enter your choice] ";
cin >> hostessChoice;
if (hostessChoice > 5 && hostessChoice < 1)
cout << "Please Enter a valid choice.";
} while (hostessChoice > 5 && hostessChoice < 1);
cin.ignore();
switch (hostessChoice)
{
case 1:
addAirHostess(airHostesses, duty_start_times, duty_end_times,
air_hostess_employee_ids, air_hostess_count);
break;
case 2:
deleteAirHostess(airHostesses, duty_start_times,
duty_end_times, air_hostess_employee_ids, air_hostess_count);
break;
case 3:
updateAirHostess(airHostesses, duty_start_times,
duty_end_times, air_hostess_employee_ids, air_hostess_count);
break;
case 4:
listAirHostesses(airHostesses, duty_start_times,
duty_end_times, air_hostess_employee_ids, air_hostess_count);
getch();
break;
case 5:
break;
default:
cout << "Invalid choice.\n";
}
} while (hostessChoice != 5);
}
else if (mainChoice == 3)
{
int flightChoice;
do
{
system("cls");
cout << " _______ ___ |__ _______ __ __
___________ ___ ___ _______ _____ ___ ____ ____ \n";
cout << " /\" \"| |\" | |\" \\ /\" _ \"| /\"
| | \"\\ (\" _ \") |\" \\ /\" | /\" \"| (\\\" \\|\" \\ (\"
_||_ \" | \n";
cout << " |: ______) || | || | (: ( \\___) (:
(__) :) )__/ \\\\__/ \\ \\ // |(: ______) |.\\\\ \\ | | ( ) :
| \n";
cout << " \\/ | |: | |: | \\/ \\ \\/
\\/ \\\\_ / /\\\\ \\/. | \\/ | |: \\. \\\\ | (: | | . )
\n";
cout << " // ___) \\ |___ |. | // \\ ___ //
__ \\\\ |. | |: \\. | // ___)_ |. \\ \\. | \\\\ \\
__/ // \n";
cout << " |: ( ( \\_|: \\ /\\ |\\ (: _( _| (: ( )
:) \\: | |. \\ /: |(: \"| | \\ \\ | /\\\\ __ //\\ \
n";
cout << " \\__/ \\_______) (__\\_|_) \\_______) \\__| |
__/ \\__| |___|\\__/|___| \\_______) \\___|\\____\\) (__________) \
n";
cout << "
\n";
cout << " " << endl;
cout <<
" ,-----------------------------------------------------------------------
-------------------------------------------," << endl;
cout << " | 1. Add Flight
2. List Flight |" << endl;
cout << " | 3. Update Flight
4. Delete Flight |" << endl;
cout << " | 5. Add Customer
6. List Customer |" << endl;
cout << " | 7. Update Customer
8. Back to Main Menu |" << endl;
cout << " \\
___________________________________________________________________________________
________________________________/" << endl;
cout << " ->->->->->->->->->->->->->->->->->->->->->->->->->->->->-
>->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->-
>->->->->-" << endl;
do
{
cout << "[Enter your choice] ";
cin >> flightChoice;
if (flightChoice > 8 && flightChoice < 1)
cout << "Invalid Choice.";
} while (flightChoice > 8 && flightChoice < 1);
cin.ignore();
int flightIndex;
switch (flightChoice)
{
case 1:
addFlight(flight_names, flight_times, flight_count);
getch();
break;
case 2:
listFlights(flight_names, flight_times, flight_count);
getch();
break;
case 3:
updateFlightTime(flight_names, flight_times, flight_count);
getch();
break;
case 4:
deleteFlight(flight_names, flight_times, flight_count);
getch();
break;
case 5:
listFlights(flight_names, flight_times, flight_count);
cout << "Enter flight index to add customer: ";
cin >> flightIndex;
cin.ignore();
if (flightIndex >= 0 && flightIndex < flight_count)
{
addCustomer(flightIndex);
}
else
{
cout << "Invalid flight index.\n";
}
getch();
break;
case 6:
{
cout << "Enter flight index to list customers: ";
cin >> flightIndex;
cin.ignore();
if (flightIndex >= 0 && flightIndex < flight_count)
{
listCustomers(flightIndex);
}
else
{
cout << "Invalid flight index.\n";
getch();
}
}
break;
case 7:
cout << "Enter flight index to update customer: ";
cin >> flightIndex;
cin.ignore();
if (flightIndex >= 0 && flightIndex < flight_count)
{
updateCustomer(flightIndex);
}
else
{
cout << "Invalid flight index.\n";
}
getch();
break;
case 8:
break;
default:
cout << "Invalid choice.\n";
getch();
break;
}
} while (flightChoice != 8);
}
else if (mainChoice == 4)
{
int weatherChoice;
do
{
system("cls");
cout << " __ __ ___ _______ __ ___________ __
__ _______ _______ ___ ___ _______ _____ ___ ____ ____ \
n";
cout << " |\" |/ \\| \"| /\" \"| /\"\"\\ (\" _
\") /\" | | \"\\ /\" \"| /\" \\ |\" \\ /\" | /\" \"| (\\\"
\\|\" \\ |\" _||_ \" | \n";
cout << " |' / \\: |(: ______) / \\ )__/ \\\\__/ (:
(__) :) (: ______)|: | \\ \\ // |(: ______) |.\\\\ \\ | | |
| : | \n";
cout << " |: /' | \\/ | /' /\\ \\ \\\\
_ / \\/ \\/ \\/ | |_____/ ) /\\\\ \\/. | \\/ | |: \\.
\\\\ | |: | | . | \n";
cout << " \\// /\\' | // ___)_ // __' \\ |. | //
__ \\\\ // ___)_ // / |: \\. | // ___)_ |. \\ \\. | | |
| | \n";
cout << " / / \\\\ |(: \"| / / \\\\ \\ \\: |
(: ( ) :) (: \"||: __ \\ |. \\ /: |(: \"| | \\ \\
| \\ \\__/ / \n";
cout << " |___/ \\___| \\_______) (___/ \\___) \\
__| \\__| |__/ \\_______)|__| \\___) |___|\\__/|___| \\_______) \\___|\\
____\\) \\_______/ \n";
cout << "
\n";
cout << " " << endl;
cout <<
" ,---------------------------------------------------------------------
---------------------------------------------," << endl;
cout << " | 1. Add Weather Condition
2. List Weather Conditions |" << endl;
cout << " | 3. Delete Weather
Conditions 4. Update Weather Conditions |" <<
endl;
cout << " | 5. Check Weather
Suitability 6. Back to Main Menu |"
<< endl;
cout << " \\
___________________________________________________________________________________
________________________________/" << endl;
cout << " ->->->->->->->->->->->->->->->->->->->->->->->->->->->->-
>->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->-
>->->->->-" << endl;
do
{
cout << "[Enter your choice] ";
cin >> weatherChoice;
if (weatherChoice < 1 && weatherChoice > 6)
cout << "Please Enter a valid choice.";
} while (weatherChoice < 1 && weatherChoice > 6);
cin.ignore();
switch (weatherChoice)
{
case 1:
addWeatherCondition(weather_dates, weather_windSpeed,
weather_visibility, weather_count);
getch();
break;
case 2:
listWeather(weather_dates, weather_windSpeed,
weather_visibility, weather_count);
getch();
break;
case 3:
deleteWeather(weather_dates, weather_windSpeed,
weather_visibility, weather_count);
getch();
break;
case 4:
updateWeather(weather_dates, weather_windSpeed,
weather_visibility, weather_count);
getch();
break;
case 5:
checkWeatherSuitability(weather_count, weather_dates,
weather_windSpeed, weather_visibility);
getch();
break;
case 6:
break;
default:
cout << "Invalid choice.Please select a valid option.\n";
}
} while (weatherChoice != 6);
}
else if (mainChoice == 5)
{
cout << "Exiting program...\n";
}
else
{
cout << "Invalid choice. Try again.\n";
}
} while (mainChoice != 5);
return 0;
}
//validations
}
//file handling functions
void loadAirHostessesFromFile(string airHostesses[], string duty_start_times[],
string duty_end_times[], string air_hostess_employee_ids[], int &air_hostess_count)
{
ifstream infile("airhostess.txt");
if (infile)
{
while (getline(infile, airHostesses[air_hostess_count]))
{
getline(infile, duty_start_times[air_hostess_count]);
getline(infile, duty_end_times[air_hostess_count]);
getline(infile, air_hostess_employee_ids[air_hostess_count]);
air_hostess_count++;
}
infile.close();
}
else
{
cout << "Unable to open file for reading.\n";
}
}
void saveAirHostessesToFile(string airHostesses[], string duty_start_times[],
string duty_end_times[], string air_hostess_employee_ids[], int air_hostess_count)
{
ofstream outfile("airhostess.txt");
for (int i = 0; i < air_hostess_count; i++)
{
outfile << airHostesses[i] << ",";
outfile << duty_start_times[i] << ",";
outfile << duty_end_times[i] <<",";
outfile << air_hostess_employee_ids[i] << endl;
}
outfile.close();
}
void loadWeatherData(string weather_dates[], int weather_windSpeed[], int
weather_visibility[], int &weather_count)
{
ifstream inFile("weather.txt", ios::in);
if (!inFile)
{
cout << "Error opening weather file!" << endl;
return;
}
if (!file.is_open())
{
cout << "Error: Unable to open file.\n";
return;
}