Advertisement
Spocoman

Cruise Games

Oct 6th, 2023
940
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.51 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     string gamer;
  8.     getline(cin, gamer);
  9.  
  10.     int games;
  11.     cin >> games;
  12.     cin.ignore();
  13.  
  14.     int volleyballGames = 0;
  15.     double volleyballScores = 0;
  16.     int tennisGames = 0;
  17.     double tennisScores = 0;
  18.     int badmintonGames = 0;
  19.     double badmintonScores = 0;
  20.  
  21.     for (int i = 0; i < games; i++) {
  22.         string game;
  23.         getline(cin, game);
  24.  
  25.         int score;
  26.         cin >> score;
  27.         cin.ignore();
  28.  
  29.         if (game == "volleyball") {
  30.             volleyballGames++;
  31.             volleyballScores += score * 1.07;
  32.         }
  33.         else if (game == "tennis") {
  34.             tennisGames++;
  35.             tennisScores += score * 1.05;
  36.         }
  37.         else {
  38.             badmintonGames++;
  39.             badmintonScores += score * 1.02;
  40.         }
  41.     }
  42.  
  43.     int averageVolleyballPoints = (int)(volleyballScores / volleyballGames);
  44.     int averageTennisPoints = (int)(tennisScores / tennisGames);
  45.     int averageBadmintonPoints = (int)(badmintonScores / badmintonGames);
  46.     int totalPoints = (int)(volleyballScores + tennisScores + badmintonScores);
  47.  
  48.     if (averageVolleyballPoints >= 75 && averageTennisPoints >= 75 && averageBadmintonPoints >= 75) {
  49.         cout << "Congratulations, " << gamer << "! You won the cruise games with " << totalPoints << " points.\n";
  50.     }
  51.     else {
  52.         cout << "Sorry, " << gamer << ", you lost. Your points are only " << totalPoints << ".";
  53.     }
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement