Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- using namespace std;
- //Function Prototype
- void displayMenu();
- void userInterface();
- void showPrice();
- void booking();
- void showReceipt();
- void showSales();
- //Global Variables
- const int cSIZE = 5;
- int customerID[cSIZE];
- int numCustomer = 0;
- int typeTicket, numAdult, numChild, totalPrice;
- static int totalSales = 0;
- char id = 'A';
- //Constants Variables
- const int normalAdult = 70;
- const int normalChild = 60;
- const int expressAdult = 120;
- const int expressChild = 90;
- int main() {
- userInterface();
- return 0;
- }
- void displayMenu() {
- cout << "Welcome to Amoosement Park Ticket Booking System!\n";
- cout << "------------------------------------------------\n";
- cout << "------------------------------------------------\n\n\n";
- cout << "Menu\n";
- cout << "1-" << " " << "Ticket Price" << endl;
- cout << "2-" << " " << "Book Ticket Now" << endl;
- cout << "3-" << " " << "Show Receipt" << endl;
- cout << "4-" << " " << "Show Sales" << endl;
- cout << "5-" << " " << "Exit" << endl;
- }
- void userInterface() {
- int option;
- do{
- displayMenu();
- cout << "Enter your option: ";
- cin >> option;
- switch(option)
- {
- case 1:
- showPrice();
- break;
- case 2:
- numCustomer++;
- customerID[numCustomer] = numCustomer ;
- id++;
- booking();
- cout<< "Customer No: " << numCustomer << endl;
- break;
- case 3: //Show receipts
- showReceipt();
- break;
- case 4: // Show sales
- showSales();
- break;
- case 5:
- exit(0);
- break;
- default:
- cout << "Invalid input!"<<endl;
- break;
- }
- }while(option!=5);
- }
- void showPrice() { //Show Price
- cout << "Amoosement Park\n";
- cout << "===========================================\n\n";
- cout << "Normal Ticket\n" << "Adult - RM" << normalAdult << "\nChild - RM" <<normalChild;
- cout << "\n\nExpress Ticket\n" << "Adult - RM" << expressAdult << "\nChild - RM" << expressChild <<"\n\n";
- }
- void booking() { //Start Booking
- if(numCustomer < cSIZE){
- cout<<"Amoosement Park Booking\n";
- cout<<"==========================\n\n";
- cout<<"Please pick the type of ticket (1-Normal Ticket / 2-Express Ticket)\n";
- cin>>typeTicket;
- while(typeTicket != 1 && typeTicket !=2) {
- cout<<"Please pick the type of ticket (1-Normal Ticket / 2-Express Ticket)\n";
- cin>>typeTicket;
- }
- if(typeTicket == 1) {
- cout<<"Normal Ticket\n\n";
- cout<<"Quantity\n";
- cout<<"================\n";
- cout<<"Adult: ";
- cin>>numAdult;
- cout<<"Child(4-11): ";
- cin>>numChild;
- totalPrice = ((numAdult*normalAdult) + (numChild*normalChild));
- cout<<"Total price: RM "<<(int)totalPrice<<endl;
- totalSales = totalSales + totalPrice;
- } else if(typeTicket == 2) {
- cout<<"Express Ticket\n\n";
- cout<<"Quantity\n";
- cout<<"================\n";
- cout<<"Adult: ";
- cin>>numAdult;
- cout<<"Child(4-11): ";
- cin>>numChild;
- totalPrice = ((numAdult*expressAdult) + (numChild*expressChild));
- cout<<"Total price: "<<(int)totalPrice<<endl;
- totalSales = totalSales + totalPrice;
- }
- }else{
- cout<<"DATA IS FULL!" << endl;
- }
- }
- void showReceipt() {
- cout<<"Customer ID: " << customerID[numCustomer] << " " << id << endl;
- cout<<"Adult: " << numAdult << endl;
- cout<<"Child: " << numChild << endl;
- cout<<"Total Price: "<< totalPrice << endl;
- }
- void showSales() {
- cout<<"Total sales: " <<endl;
- cout<<totalSales<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement