#include #include #include #include #include #include #include #include #include #include #include # define AIRLINES_M using namespace std; const double TAX = 0.1; class Airline { private: string tickettype; double ticketprice; int ticketquantity; public: Airline(string, double, int); void setticketquantity(int); string gettickettype() const; int getticketquantity() const; double getticketprice() const; double getTicketSubtotal() const; double gettax() const; double subtotal; }; int main() { string strOpt; int iTemp; static int iCounter = 0; ofstream outputfile; const int SIZE = 3; Airline airlines[SIZE] = { Airline("Standard", 250.0, 0), Airline("Economy", 350.0, 0), Airline("Standard", 450.0, 0) }; const char Standard = 'A', Economy = 'B', Business = 'C', Quit = 'D'; do { cout << "\tAirlines Ticket Menu\n"; cout << "A. Standard Ticket" << "\t$250.00 each\n"; cout << "B. Economy Ticket" << "\t$350.00 each\n"; cout << "C. Business Ticket" << "\t$450.00 each\n"; cout << "D. Quit the menu"; cout << "\nPlease enter your choice of A, B, C, or D: "; getline(cin, strOpt); switch (toupper(strOpt[0])) { case Standard: cout << "\nHow many tickets would you like to purchase? "; cin >> iTemp; airlines[0].setticketquantity(iTemp); cout << airlines[0].gettickettype() << ": $" << airlines[0].getticketprice() << " Each" << "\tTicket: "; cout << iTemp << "\tCharge: $" << setw(7) << airlines[0].getticketprice() * iTemp; cout << "\tTax: $" << setw(7) << airlines[0].getticketprice() * iTemp * TAX << endl; outputfile << airlines[0].getTicketSubtotal(); iCounter++; break; default: cout << "The valid menu choices are from A through D only. \n"; } for (int i = 0; i < 3; i++) { cout << "Total " << airlines[i].gettickettype() << "\t" << "Ticket: " << airlines[i].getticketquantity(); cout << "\tCharge: $" << setw(7) << airlines[i].getTicketSubtotal() << "\tTax: $" << setw(7) << airlines[i].gettax(); } double subtotal = 0; for (int i = 0; i < 3; i++) subtotal += airlines[i].getTicketSubtotal(); cout << "\nSub Total: \t" << setw(15) << subtotal << endl; cout << "Tax: \t\t" << setw(15) << subtotal * TAX; cout << endl << "\nTotal charges: \t" << setw(15) << (i + TAX) * subtotal << endl << endl; } while (toupper(strOpt[0] != Quit)); outputfile.close(); cout << endl << "Enjoy your flight! \n"; cout << "See you next time. \n"; cout << "\nIf you are a custmoer, you can exit this program now.\n"; cout << "Please enter 'Y/y' for yes or 'N/n' if you would like to continue: "; getline(cin, strOpt); if (toupper(strOpt[0]) == 'Y') { cout << "\nThank you for the business! \n"; cout << "Please press the enter key to exit."; cin.get(); return 0; } else cout << "\nPlease continue this program. \n"; return 0; } int binaryseach(int iArray[], int iSize, int iMin, int iMax, int iValue) { if (iMax < iMin) return -1; else { int iMid = (iMin + iMax) / 2; if (iArray[iMid] > iValue) return binaryseach(iArray, iSize, iMid, iMid - 1, iValue); else if (iArray[iMid] < iValue) return binaryseach(iArray, iSize, iMid + 1, iMax, iValue); else return iMid; } } Airline::Airline(string type, double price, int quantity) { tickettype = type; ticketprice = price; ticketquantity = quantity; } void Airline::setticketquantity(int quantity) { ticketquantity += quantity; } int Airline::getticketquantity() const { return ticketquantity; } double Airline::getticketprice() const { return ticketprice; } string Airline::gettickettype() const { return tickettype; } double Airline::getTicketSubtotal() const { return ticketprice * ticketquantity; } double Airline::gettax() const { return getTicketSubtotal() * TAX; }