Advertisement
Guest User

Untitled

a guest
Dec 12th, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.77 KB | None | 0 0
  1. #include <iostream>
  2. #include<string.h>
  3. #include<ctype.h>
  4. using namespace std;
  5.  
  6. int calcAdult(char);
  7. int calcKids(char);
  8.  
  9. void dispMostPeople(int,int);
  10. void dispOutput(int,int,float);
  11. main()
  12. {
  13.     int age,stop,sum=0,count=0,kids=0,adult=0;
  14.     float ticket_price,average;
  15.     char ticket;
  16.     bool choice = true;
  17.  
  18.     cout << " WELCOME TO NISSAN STADIUM SYSTEM'S TICKET\n ~THE HOME OF THE SAILORS!!!~.";
  19.     cout << "\n TICKET INFORMATION";
  20.     cout << "\n--------------------------------------------------------------------";
  21.     cout << "\n~|YOKOHAMA F-MARINOS VS URAWA REDS DIAMONDS|~";
  22.     cout << "\n\tJ1 LEAGUE MATCHES";
  23.     cout << "\n DATE:31ST DECEMBER 2017,TIME:2000 HRS(JAPANESE TIME)";
  24.     cout << "\n\n<(A)SS-WEST GATE>[ADULT(5,300 JPY)/KIDS(2,100 JPY)]\n<(B)NON RESERVED SEAT(NORTH GATE,EAST GATE)>[ADULT(2,500 JPY)/KIDS(1,000 JPY)]\n<(C)AWAY FANS(SOUTH GATE)>[ADULT(2,500 JPY)/KIDS(1,000 JPY)]";
  25.     cout << "\n\n***PLEASE NOTED THAT THE KIDS TICKET IS ONLY APPLIED TO THE KIDS UNDER 15 YEARS OLD***";
  26.    
  27.     while(choice)
  28.     {
  29.         cout << "\n\nEnter your age:";
  30.         cin >> age;
  31.         cout <<"Select your ticket category:";
  32.         cin >> ticket;
  33.         ticket = toupper(ticket);
  34.         if(age>=15)
  35.             {
  36.                 ticket_price=calcAdult(ticket);
  37.                 adult++;
  38.             }
  39.        
  40.         else
  41.             if(age > 0 && age < 15)
  42.             {
  43.                 ticket_price =calcKids(ticket);
  44.                 kids++;
  45.             }
  46.         else
  47.             cout <<"Sorry!but your choice is invalid!!!";
  48.             sum = sum + ticket_price;
  49.             count++;
  50.             average = sum/count;
  51.             cout << "Press 0 if you want to stop or another button to continue:";
  52.             cin >> stop;
  53.            
  54.             if(stop==0)
  55.                 choice=false;
  56.         }
  57.         dispMostPeople(kids,adult);
  58.         dispOutput(sum,count,average);
  59.        
  60.     }
  61.        
  62.        
  63.  
  64.  
  65. int calcAdult(char tic)
  66. {
  67.     int a=0,b=0,price;
  68.     if (tic == 'A')
  69.         price=5300;    
  70.     else
  71.         if(tic == 'B')
  72.             price=2500;
  73.     else
  74.         if(tic=='C')
  75.             price=2500;
  76.     else
  77.         cout <<"Sorry!but your choice is invalid!!!";
  78.            
  79.     return price;
  80.            
  81. }
  82. int calcKids(char tic)
  83. {
  84.     int price;
  85.     if (tic == 'A')
  86.         price=2100;    
  87.     else
  88.         if(tic == 'B')
  89.             price=1000;
  90.     else
  91.         if(tic=='C')
  92.             price=1000;
  93.     else
  94.         cout <<"Sorry!but your choice is invalid!!!";
  95.            
  96.     return price;
  97. }
  98.  
  99.  
  100.  
  101. void dispMostPeople(int kid,int adlt)
  102. {
  103.     if(adlt > kid)
  104.         cout << "\nThe most people who like to come to the stadium was adult with "<< adlt << " people";
  105.     else
  106.         if(kid > adlt)
  107.         cout << "\nThe most people who like to come to the stadium was kids with "<< kid<< " people";
  108.     else
  109.         cout << "\nThe number of the adult and kids fans are same with "<< adlt << " people";
  110. }
  111.  
  112. void dispOutput(int s,int c,float avg)
  113. {
  114.     cout <<"\nYou want to buy :"<< c <<" tickets";
  115.     cout <<"\nThe total price is :"<< s <<" JPY";
  116.     cout <<"\nThe average ticket price for one person is :"<< avg << " JPY";
  117.     cout <<"\nThank you and enjoy your match :) ";
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement