SHARE
TWEET

Untitled

a guest Dec 8th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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(int numCustomer);
  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.  
  22. //Constants Variables
  23. const int normalAdult = 70;
  24. const int normalChild = 60;
  25. const int expressAdult = 120;
  26. const int expressChild = 90;
  27.  
  28.  
  29. int main() {
  30.   userInterface();
  31.  
  32.   return 0;
  33. }
  34.  
  35. void displayMenu() {
  36.   cout << "Welcome to Amoosement Park Ticket Booking System!\n";
  37.   cout << "------------------------------------------------\n";
  38.   cout << "------------------------------------------------\n\n\n";
  39.   cout << "Menu\n";
  40.   cout << "1-" << " " << "Ticket Price" << endl;
  41.   cout << "2-" << " " << "Book Ticket Now" << endl;
  42.   cout << "3-" << " " << "Show Receipt" << endl;
  43.   cout << "4-" << " " << "Show Sales" << endl;
  44.   cout << "5-" << " " << "Exit" << endl;
  45. }
  46.  
  47. void userInterface() {
  48.   int option, numAdult, numChild;
  49.  
  50.  
  51.  
  52.  
  53.     for(numCustomer=0; numCustomer <= cSIZE; numCustomer) {
  54.     displayMenu();
  55.   cout << "Enter your option: ";
  56.   cin >> option;
  57.  
  58.   switch(option)
  59.   {
  60.       case 1:
  61.         showPrice();
  62.       break;
  63.  
  64.  
  65.       case 2:
  66.  
  67.  
  68.         booking(numCustomer);
  69.         numCustomer++;
  70.         customerID[numCustomer];
  71.         cout<< "Customer No: " << numCustomer << endl;
  72.  
  73.       break;
  74.  
  75.       case 3: //Show receipts
  76.         showReceipt();
  77.         break;
  78.  
  79.         case 4: // Show sales
  80.           showSales();
  81.           break;
  82.  
  83.           case 5:
  84.           exit(0);
  85.           break;
  86.  
  87.       default:
  88.         cout << "Invalid input!"<<endl;
  89.         break;
  90.   }
  91.  
  92. }//forloop
  93.  
  94. do{
  95.   displayMenu();
  96.   cout << "Enter your option: ";
  97.   cin >> option;
  98.  
  99.   switch(option)
  100.   {
  101.       case 1:
  102.         showPrice();
  103.       break;
  104.  
  105.  
  106.       case 2:
  107.  
  108.         booking(numCustomer);
  109.         numCustomer++;
  110.         customerID[numCustomer];
  111.         cout<< "Customer No: " << numCustomer << endl;
  112.  
  113.       break;
  114.  
  115.       case 3: //Show receipts
  116.         showReceipt();
  117.         break;
  118.  
  119.         case 4: // Show sales
  120.           showSales();
  121.           break;
  122.  
  123.           case 5:
  124.           exit(0);
  125.           break;
  126.  
  127.       default:
  128.         cout << "Invalid input!"<<endl;
  129.         break;
  130.   }
  131. }while(option!=5);
  132.  
  133. }
  134.  
  135. void showPrice() { //Show Price
  136.   cout << "Amoosement Park\n";
  137.   cout << "===========================================\n\n";
  138.   cout << "Normal Ticket\n" << "Adult - RM" << normalAdult << "\nChild - RM" <<normalChild;
  139.   cout << "\n\nExpress Ticket\n" << "Adult - RM" << expressAdult << "\nChild - RM" << expressChild <<"\n\n";
  140. }
  141.  
  142. void booking(int customerNo) { //Start Booking
  143.  
  144.   if(customerNo < cSIZE){
  145.   cout<<"Amoosement Park Booking\n";
  146.   cout<<"==========================\n\n";
  147.  
  148.  
  149.   cout<<"Please pick the type of ticket (1-Normal Ticket / 2-Express Ticket)\n";
  150.   cin>>typeTicket;
  151.  
  152.   while(typeTicket != 1 && typeTicket !=2) {
  153.     cout<<"Please pick the type of ticket (1-Normal Ticket / 2-Express Ticket)\n";
  154.     cin>>typeTicket;
  155.   }
  156.  
  157.   if(typeTicket == 1) {
  158.     cout<<"Normal Ticket\n\n";
  159.     cout<<"Quantity\n";
  160.     cout<<"================\n";
  161.     cout<<"Adult: ";
  162.     cin>>numAdult;
  163.     cout<<"Child(4-11): ";
  164.     cin>>numChild;
  165.  
  166.     totalPrice = ((numAdult*normalAdult) + (numChild*normalChild));
  167.     cout<<"Total price: RM "<<(int)totalPrice<<endl;
  168.     totalSales = totalSales + totalPrice;
  169.  
  170.  
  171.  
  172.   } else if(typeTicket == 2) {
  173.     cout<<"Express Ticket\n\n";
  174.     cout<<"Quantity\n";
  175.     cout<<"================\n";
  176.     cout<<"Adult: ";
  177.     cin>>numAdult;
  178.     cout<<"Child(4-11): ";
  179.     cin>>numChild;
  180.  
  181.  
  182.     totalPrice = ((numAdult*expressAdult) + (numChild*expressChild));
  183.     cout<<"Total price: "<<(int)totalPrice<<endl;
  184.     totalSales = totalSales + totalPrice;
  185.  
  186.  
  187.  
  188.  
  189.   }
  190. }else{
  191.   cout<<"DATA IS FULL!" << endl;
  192. }
  193. }
  194.  
  195.  
  196. void showReceipt() {
  197.   cout<<"Customer ID: " << customerID[numCustomer] << endl;
  198.   cout<<"Adult: " << numAdult << endl;
  199.   cout<<"Child: " << numChild << endl;
  200.   cout<<"Total Price: "<< totalPrice << endl;
  201. }
  202.  
  203. void showSales() {
  204.   cout<<"Total sales: " <<endl;
  205.   cout<<totalSales<<endl;
  206. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top