Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main() {
- string gamer;
- getline(cin, gamer);
- int games;
- cin >> games;
- cin.ignore();
- int volleyballGames = 0;
- double volleyballScores = 0;
- int tennisGames = 0;
- double tennisScores = 0;
- int badmintonGames = 0;
- double badmintonScores = 0;
- for (int i = 0; i < games; i++) {
- string game;
- getline(cin, game);
- int score;
- cin >> score;
- cin.ignore();
- if (game == "volleyball") {
- volleyballGames++;
- volleyballScores += score * 1.07;
- }
- else if (game == "tennis") {
- tennisGames++;
- tennisScores += score * 1.05;
- }
- else {
- badmintonGames++;
- badmintonScores += score * 1.02;
- }
- }
- int averageVolleyballPoints = (int)(volleyballScores / volleyballGames);
- int averageTennisPoints = (int)(tennisScores / tennisGames);
- int averageBadmintonPoints = (int)(badmintonScores / badmintonGames);
- int totalPoints = (int)(volleyballScores + tennisScores + badmintonScores);
- if (averageVolleyballPoints >= 75 && averageTennisPoints >= 75 && averageBadmintonPoints >= 75) {
- cout << "Congratulations, " << gamer << "! You won the cruise games with " << totalPoints << " points.\n";
- }
- else {
- cout << "Sorry, " << gamer << ", you lost. Your points are only " << totalPoints << ".";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement