Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main() {
- int seats,
- kidTickets = 0, studentTickets = 0, standardTickets = 0;
- string movie, category;
- getline(cin, movie);
- while (movie != "Finish") {
- cin >> seats;
- int counter = 0;
- for (int i = 0; i < seats; i++) {
- cin >> category;
- if (category == "student") {
- studentTickets++;
- }
- else if (category == "standard") {
- standardTickets++;
- }
- else if (category == "kid") {
- kidTickets++;
- }
- else {
- break;
- }
- counter++;
- }
- printf("%s - %.2f%% full.\n", movie.c_str(), 1.0 * counter / seats * 100);
- cin.ignore();
- getline(cin, movie);
- }
- int sumTickets = standardTickets + studentTickets + kidTickets;
- cout.setf(ios::fixed);
- cout.precision(2);
- cout << "Total tickets: " << sumTickets << endl
- << 1.0 * studentTickets / sumTickets * 100 << "% student tickets.\n"
- << 1.0 * standardTickets / sumTickets * 100 << "% standard tickets.\n"
- << 1.0 * kidTickets / sumTickets * 100 << "% kids tickets.\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement