Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3. using namespace std;
  4.  
  5. //Function Prototype
  6. void displayMenu();
  7. void userInterface();
  8. void showPrice();
  9. void booking();
  10. void showReceipt();
  11. void showSales();
  12.  
  13.  
  14.  
  15. //Global Variables
  16. const int cSIZE = 5;
  17. int customerID[cSIZE];
  18. int numCustomer = 0;
  19. int typeTicket, numAdult, numChild, totalPrice;
  20. static int totalSales = 0;
  21. char id = 'A';
  22.  
  23. //Constants Variables
  24. const int normalAdult = 70;
  25. const int normalChild = 60;
  26. const int expressAdult = 120;
  27. const int expressChild = 90;
  28.  
  29.  
  30. int main() {
  31.   userInterface();
  32.  
  33.   return 0;
  34. }
  35.  
  36. void displayMenu() {
  37.   cout << "Welcome to Amoosement Park Ticket Booking System!\n";
  38.   cout << "------------------------------------------------\n";
  39.   cout << "------------------------------------------------\n\n\n";
  40.   cout << "Menu\n";
  41.   cout << "1-" << " " << "Ticket Price" << endl;
  42.   cout << "2-" << " " << "Book Ticket Now" << endl;
  43.   cout << "3-" << " " << "Show Receipt" << endl;
  44.   cout << "4-" << " " << "Show Sales" << endl;
  45.   cout << "5-" << " " << "Exit" << endl;
  46. }
  47.  
  48. void userInterface() {
  49.   int option;
  50.  
  51. do{
  52.   displayMenu();
  53.   cout << "Enter your option: ";
  54.   cin >> option;
  55.  
  56.   switch(option)
  57.   {
  58.       case 1:
  59.         showPrice();
  60.       break;
  61.  
  62.  
  63.       case 2:
  64.  
  65.         numCustomer++;
  66.         customerID[numCustomer] = numCustomer ;
  67.         id++;
  68.         booking();
  69.  
  70.         cout<< "Customer No: " << numCustomer << endl;
  71.  
  72.       break;
  73.  
  74.       case 3: //Show receipts
  75.         showReceipt();
  76.         break;
  77.  
  78.         case 4: // Show sales
  79.           showSales();
  80.           break;
  81.  
  82.           case 5:
  83.           exit(0);
  84.           break;
  85.  
  86.       default:
  87.         cout << "Invalid input!"<<endl;
  88.         break;
  89.   }
  90. }while(option!=5);
  91.  
  92. }
  93.  
  94. void showPrice() { //Show Price
  95.   cout << "Amoosement Park\n";
  96.   cout << "===========================================\n\n";
  97.   cout << "Normal Ticket\n" << "Adult - RM" << normalAdult << "\nChild - RM" <<normalChild;
  98.   cout << "\n\nExpress Ticket\n" << "Adult - RM" << expressAdult << "\nChild - RM" << expressChild <<"\n\n";
  99. }
  100.  
  101. void booking() { //Start Booking
  102.  
  103.   if(numCustomer < cSIZE){
  104.   cout<<"Amoosement Park Booking\n";
  105.   cout<<"==========================\n\n";
  106.  
  107.  
  108.   cout<<"Please pick the type of ticket (1-Normal Ticket / 2-Express Ticket)\n";
  109.   cin>>typeTicket;
  110.  
  111.   while(typeTicket != 1 && typeTicket !=2) {
  112.     cout<<"Please pick the type of ticket (1-Normal Ticket / 2-Express Ticket)\n";
  113.     cin>>typeTicket;
  114.   }
  115.  
  116.   if(typeTicket == 1) {
  117.     cout<<"Normal Ticket\n\n";
  118.     cout<<"Quantity\n";
  119.     cout<<"================\n";
  120.     cout<<"Adult: ";
  121.     cin>>numAdult;
  122.     cout<<"Child(4-11): ";
  123.     cin>>numChild;
  124.  
  125.     totalPrice = ((numAdult*normalAdult) + (numChild*normalChild));
  126.     cout<<"Total price: RM "<<(int)totalPrice<<endl;
  127.     totalSales = totalSales + totalPrice;
  128.  
  129.  
  130.  
  131.   } else if(typeTicket == 2) {
  132.     cout<<"Express Ticket\n\n";
  133.     cout<<"Quantity\n";
  134.     cout<<"================\n";
  135.     cout<<"Adult: ";
  136.     cin>>numAdult;
  137.     cout<<"Child(4-11): ";
  138.     cin>>numChild;
  139.  
  140.  
  141.     totalPrice = ((numAdult*expressAdult) + (numChild*expressChild));
  142.     cout<<"Total price: "<<(int)totalPrice<<endl;
  143.     totalSales = totalSales + totalPrice;
  144.  
  145.  
  146.  
  147.  
  148.   }
  149. }else{
  150.   cout<<"DATA IS FULL!" << endl;
  151. }
  152. }
  153.  
  154.  
  155. void showReceipt() {
  156.   cout<<"Customer ID: " << customerID[numCustomer] << " " << id << endl;
  157.   cout<<"Adult: " << numAdult << endl;
  158.   cout<<"Child: " << numChild << endl;
  159.   cout<<"Total Price: "<< totalPrice << endl;
  160. }
  161.  
  162. void showSales() {
  163.   cout<<"Total sales: " <<endl;
  164.   cout<<totalSales<<endl;
  165. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement