Advertisement
mark79

Criuze Games

Jul 30th, 2019
596
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.89 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class CruiseGames {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         String playerName = scanner.nextLine();
  8.         int totalGames = Integer.parseInt(scanner.nextLine());
  9.  
  10.         int volleyballGames = 0;
  11.         int tennisGames = 0;
  12.         int badmintonGames = 0;
  13.  
  14.         double volleyballPoints = 0;
  15.         double tennisPoints = 0;
  16.         double badmintonPoints = 0;
  17.         for (int i = 0; i < totalGames; i++) {
  18.             String gameName = scanner.nextLine();
  19.             double gamePoints = Double.parseDouble(scanner.nextLine());
  20.             switch (gameName) {
  21.                 case "volleyball":
  22.                     volleyballPoints += gamePoints * 1.07;
  23.                     volleyballGames++;
  24.                     break;
  25.                 case "tennis":
  26.                     tennisPoints += gamePoints * 1.05;
  27.                     tennisGames++;
  28.                     break;
  29.                 case "badminton":
  30.                     badmintonPoints += gamePoints * 1.02;
  31.                     badmintonGames++;
  32.                     break;
  33.             }
  34.         }
  35.         int avgVolleyballPoints = (int) Math.floor(volleyballPoints / volleyballGames);
  36.         int avgTennisPoints = (int) Math.floor(tennisPoints / tennisGames);
  37.         int avgBadmintonPoints = (int) Math.floor(badmintonPoints / badmintonGames);
  38.         boolean isWinner = avgBadmintonPoints >= 75 && avgTennisPoints >= 75 && avgVolleyballPoints >= 75;
  39.         int totalPoints = (int) Math.floor(volleyballPoints + tennisPoints + badmintonPoints);
  40.         if (isWinner) {
  41.             System.out.printf("Congratulations, %s! You won the cruise games with %d points.", playerName, totalPoints);
  42.         } else {
  43.             System.out.printf("Sorry, %s, you lost. Your points are only %d.", playerName, totalPoints);
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement