Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # include <iostream>
- using namespace std;
- #include <iomanip>
- #include <math.h>
- #include <cmath>
- #include <string>
- int main()
- {
- string name;
- int places;
- string ticket;
- double studentcounter = 0;
- double standartcounter = 0;
- double kidcounter = 0;
- int totalplaces = 0;
- int alltickets = 0;
- getline(cin, name);
- while (name != "Finish") {
- cin >> places;
- totalplaces += places;
- double placescounter = 0;
- while (places - placescounter > 0) {
- cin >> ticket;
- if (ticket == "End") {
- break;
- }
- if (ticket == "student") {
- studentcounter += 1;
- placescounter += 1;
- alltickets += 1;
- }
- else if (ticket == "standard") {
- standartcounter += 1;
- placescounter += 1;
- alltickets += 1;
- }
- else if (ticket == "kid") {
- kidcounter += 1;
- placescounter += 1;
- alltickets += 1;
- }
- }
- cout << name << " - " << fixed << setprecision(2) << placescounter / places * 100 << "% full." << endl;
- cin.ignore();
- getline(cin, name);
- }
- cout << "Total tickets: " << alltickets << endl;
- cout << fixed << setprecision(2) << studentcounter / alltickets * 100 << "% student tickets." << endl;
- cout << fixed << setprecision(2) << standartcounter / alltickets * 100 << "% standard tickets." << endl;
- cout << fixed << setprecision(2) << kidcounter / alltickets * 100 << "% kids tickets." << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement