Advertisement
JOHNYTHEWINNER

Cinema tickets

Feb 16th, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.38 KB | None | 0 0
  1. # include <iostream>
  2. using namespace std;
  3. #include <iomanip>
  4. #include <math.h>
  5. #include <cmath>
  6. #include <string>
  7.  
  8. int main()
  9. {
  10.     string name;
  11.     int places;
  12.     string ticket;
  13.     double studentcounter = 0;
  14.     double standartcounter = 0;
  15.     double kidcounter = 0;
  16.     int totalplaces = 0;
  17.     int alltickets = 0;
  18.     getline(cin, name);
  19.     while (name != "Finish") {
  20.         cin >> places;
  21.         totalplaces += places;
  22.         double placescounter = 0;
  23.         while (places - placescounter > 0) {
  24.             cin >> ticket;
  25.             if (ticket == "End") {
  26.                 break;
  27.             }
  28.             if (ticket == "student") {
  29.                 studentcounter += 1;
  30.                 placescounter += 1;
  31.                 alltickets += 1;
  32.             }
  33.             else if (ticket == "standard") {
  34.                 standartcounter += 1;
  35.                 placescounter += 1;
  36.                 alltickets += 1;
  37.             }
  38.             else if (ticket == "kid") {
  39.                 kidcounter += 1;
  40.                 placescounter += 1;
  41.                 alltickets += 1;
  42.             }
  43.         }
  44.         cout << name << " - " << fixed << setprecision(2) << placescounter / places * 100 << "% full." << endl;
  45.         cin.ignore();
  46.         getline(cin, name);
  47.     }
  48.     cout << "Total tickets: " << alltickets << endl;
  49.     cout << fixed << setprecision(2) << studentcounter / alltickets * 100 << "% student tickets." << endl;
  50.     cout << fixed << setprecision(2) << standartcounter / alltickets * 100 << "% standard tickets." << endl;
  51.     cout << fixed << setprecision(2) << kidcounter / alltickets * 100 << "% kids tickets." << endl;
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement