Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class CruiseGames {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String playerName = scanner.nextLine();
- int totalGames = Integer.parseInt(scanner.nextLine());
- int volleyballGames = 0;
- int tennisGames = 0;
- int badmintonGames = 0;
- double volleyballPoints = 0;
- double tennisPoints = 0;
- double badmintonPoints = 0;
- for (int i = 0; i < totalGames; i++) {
- String gameName = scanner.nextLine();
- double gamePoints = Double.parseDouble(scanner.nextLine());
- switch (gameName) {
- case "volleyball":
- volleyballPoints += gamePoints * 1.07;
- volleyballGames++;
- break;
- case "tennis":
- tennisPoints += gamePoints * 1.05;
- tennisGames++;
- break;
- case "badminton":
- badmintonPoints += gamePoints * 1.02;
- badmintonGames++;
- break;
- }
- }
- int avgVolleyballPoints = (int) Math.floor(volleyballPoints / volleyballGames);
- int avgTennisPoints = (int) Math.floor(tennisPoints / tennisGames);
- int avgBadmintonPoints = (int) Math.floor(badmintonPoints / badmintonGames);
- boolean isWinner = avgBadmintonPoints >= 75 && avgTennisPoints >= 75 && avgVolleyballPoints >= 75;
- int totalPoints = (int) Math.floor(volleyballPoints + tennisPoints + badmintonPoints);
- if (isWinner) {
- System.out.printf("Congratulations, %s! You won the cruise games with %d points.", playerName, totalPoints);
- } else {
- System.out.printf("Sorry, %s, you lost. Your points are only %d.", playerName, totalPoints);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement