Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2020
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.53 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3. #include<cmath>
  4. using namespace std;
  5. int main()
  6. {
  7.     string playerName;
  8.     int gamesPlayed;
  9.  
  10.     getline(cin, playerName);
  11.     cin >> gamesPlayed;
  12.  
  13.     string gameType;
  14.     double currentPoints;
  15.  
  16.     int volleyballGamesCount = 0;
  17.     int tennisGamesCount = 0;
  18.     int badmintonGamesCount = 0;
  19.  
  20.     double volleyBallPoints = 0;
  21.     double tennisPoints = 0;
  22.     double badmintonPoints = 0;
  23.  
  24.  
  25.  
  26.     for (int game = 1; game <= gamesPlayed; game++)
  27.     {
  28.         cin >> gameType;
  29.         cin >> currentPoints;
  30.  
  31.         if (gameType == "volleyball")
  32.         {
  33.             currentPoints = currentPoints + currentPoints * 0.07;
  34.             volleyballGamesCount++;
  35.             volleyBallPoints += currentPoints;
  36.         }
  37.         else if (gameType == "tennis")
  38.         {
  39.             currentPoints = currentPoints + currentPoints * 0.05;
  40.             tennisGamesCount++;
  41.             tennisPoints += currentPoints;
  42.         }
  43.         else if (gameType == "badminton")
  44.         {
  45.             currentPoints = currentPoints + currentPoints * 0.02;
  46.             badmintonGamesCount++;
  47.             badmintonPoints += currentPoints;
  48.         }
  49.  
  50.     }
  51.  
  52.     double totalPoints = volleyBallPoints + tennisPoints + badmintonPoints;
  53.  
  54.     if (floor(volleyBallPoints / volleyballGamesCount) >= 75)
  55.     {
  56.         if (floor(tennisPoints / tennisGamesCount) >= 75)
  57.         {
  58.             if (floor(badmintonPoints / badmintonGamesCount) >= 75)
  59.             {
  60.                 cout << "Congratulations, " << playerName << "! You won the cruise games with " << floor(totalPoints) << " points." << endl;
  61.             }
  62.         }
  63.     }
  64.     else
  65.     {
  66.         cout << "Sorry, " << playerName << ", you lost. Your points are only " << floor(totalPoints) << "." << endl;
  67.     }
  68.  
  69.    
  70.  
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement