rendered paste body // Call the function printBookings (to print the current status -
// all flights have 0 bookings.
printBookings(bookings, 10);
input >> trans_type >> flight_num >> seats;
while(!input.eof()) {
//debug cout << trans_type << " " << flight_num << " " << seats;
if (trans_type == BOOK_FLIGHT) {
// book flight
bookings[flight_num]+=seats;
log << seats << " added to flight #" << flight_num << "." << endl;
} else if (trans_type == CANCEL_FLIGHT) {
// cancel flight
if (bookings[flight_num] < seats) {
log << "ERROR: Cannot cancel " << seats << " in flight #"
<< flight_num<<" when flight #"<<flight_num << " only has "
<< bookings[flight_num] << " seats reserved." << endl;
} else {
bookings[flight_num]-=seats;
log << seats << " canceled from flight #" << flight_num <<".\n";
}
} else {
// invalid!
cout << "There is an invalid transaction type in the data file or the data file is corrupted! *Cries*" << endl;
log << "Invalid data!" << endl;
log.close();
input.close();
return 0;
}
input >> trans_type >> flight_num >> seats;
}
// Call the function printBookings
printBookings(bookings, 10);
Income(bookings, 10, 120);
}