SHARE
TWEET

Cinema Tickets

Nephelir Feb 18th, 2020 159 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string>
  3. #include <math.h>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     string movie;
  10.     getline(cin, movie);
  11.  
  12.     int studentCounter = 0;
  13.     int standartCounter = 0;
  14.     int kidsCounter = 0;
  15.  
  16.     cout.setf(ios::fixed);
  17.     cout.precision(2);
  18.  
  19.     while (movie != "Finish")
  20.     {
  21.         int capacity;
  22.         cin >> capacity;
  23.  
  24.         int CurrentMovieCnt = 0;
  25.  
  26.         for (int i = 0; i < capacity; i++)
  27.         {
  28.             string ticketType;
  29.             cin >> ticketType;
  30.  
  31.             if (ticketType == "End")
  32.             {
  33.                 break;
  34.             }
  35.  
  36.             CurrentMovieCnt++;
  37.  
  38.             if (ticketType == "student")
  39.             {
  40.                 studentCounter++;
  41.             }
  42.             else if (ticketType == "standart")
  43.             {
  44.                 standartCounter++;
  45.             }
  46.             else if (ticketType == "kid")
  47.             {
  48.                 kidsCounter++;
  49.             }
  50.  
  51.         }
  52.         double percent = CurrentMovieCnt * 1.0 / capacity * 100;
  53.         cout << movie << " - " << percent << "% full." << endl;
  54.         cin.ignore();
  55.         getline(cin, movie);
  56.     }
  57.  
  58.     int totalTickets = studentCounter + standartCounter + kidsCounter;
  59.     cout << "Total tickets: " << totalTickets << endl;
  60.     double studentPersent = studentCounter * 1.0 / totalTickets * 100;
  61.     cout << studentPersent << "% standart tickets." << endl;
  62.     double standartPercent = standartCounter * 1.0 / totalTickets * 100;
  63.     cout << standartPercent << "% standart tickets." << endl;
  64.     double kidsPersent = kidsCounter * 1.0 / totalTickets * 100;
  65.     cout << kidsPersent << "% standart tickets." << endl;
  66.  
  67.     return 0;
  68. }
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
Top