Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.43 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main()  // vlojeni cikli izpitni                            // printf(%d %d %d\n, a, b, c); === shablon,  \n === nov red
  7. {
  8.     string movie;
  9.     getline(cin, movie);
  10.     int kidType = 0;
  11.     int standardType = 0;
  12.     int studentType = 0;
  13.     cout.setf(ios::fixed);
  14.     cout.precision(2);
  15.     while (movie != "Finish")
  16.     {
  17.         int capacity;
  18.         cin >> capacity;
  19.         int currentMovieCount = 0;
  20.         for (int i = 0; i < capacity; i++)
  21.         {
  22.             string ticketType;
  23.             cin >> ticketType;
  24.             if (ticketType == "End")
  25.             {
  26.                 break;
  27.             }
  28.             currentMovieCount++;
  29.             if (ticketType == "standard")
  30.             {
  31.                 standardType++;
  32.             }
  33.             if (ticketType == "student")
  34.             {
  35.                 studentType++;
  36.             }
  37.             if (ticketType == "kid")
  38.             {
  39.                 kidType++;
  40.             }
  41.         }
  42.         double percent = currentMovieCount * 1.0 / capacity * 100;
  43.         cout << movie << " - " << percent << "% full." << endl;
  44.         cin.ignore();
  45.         getline(cin, movie);
  46.     }
  47.     int totalTickets = standardType + studentType + kidType;
  48.     cout << "Total tickets: " << totalTickets << endl;
  49.     double studentPercent = studentType * 1.0 / totalTickets * 100;
  50.     double standardPercent = standardType * 1.0 / totalTickets * 100;
  51.     double kidPercent = kidType * 1.0 / totalTickets * 100;
  52.     cout << studentPercent << "% student tickets." << endl;
  53.     cout << standardPercent << "% standard tickets." << endl;
  54.     cout << kidPercent << "% kids tickets." << endl;
  55.  
  56.     return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement