Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- #include<cmath>
- using namespace std;
- int main()
- {
- string playerName;
- int gamesPlayed;
- getline(cin, playerName);
- cin >> gamesPlayed;
- string gameType;
- double currentPoints;
- int volleyballGamesCount = 0;
- int tennisGamesCount = 0;
- int badmintonGamesCount = 0;
- double volleyBallPoints = 0;
- double tennisPoints = 0;
- double badmintonPoints = 0;
- for (int game = 1; game <= gamesPlayed; game++)
- {
- cin >> gameType;
- cin >> currentPoints;
- if (gameType == "volleyball")
- {
- currentPoints = currentPoints + currentPoints * 0.07;
- volleyballGamesCount++;
- volleyBallPoints += currentPoints;
- }
- else if (gameType == "tennis")
- {
- currentPoints = currentPoints + currentPoints * 0.05;
- tennisGamesCount++;
- tennisPoints += currentPoints;
- }
- else if (gameType == "badminton")
- {
- currentPoints = currentPoints + currentPoints * 0.02;
- badmintonGamesCount++;
- badmintonPoints += currentPoints;
- }
- }
- double totalPoints = volleyBallPoints + tennisPoints + badmintonPoints;
- if (floor(volleyBallPoints / volleyballGamesCount) >= 75)
- {
- if (floor(tennisPoints / tennisGamesCount) >= 75)
- {
- if (floor(badmintonPoints / badmintonGamesCount) >= 75)
- {
- cout << "Congratulations, " << playerName << "! You won the cruise games with " << floor(totalPoints) << " points." << endl;
- }
- }
- }
- else
- {
- cout << "Sorry, " << playerName << ", you lost. Your points are only " << floor(totalPoints) << "." << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement