Advertisement
Spocoman

Cruise Games

Sep 4th, 2024
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.63 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         String gamer = scanner.nextLine(), game;
  7.         int games = Integer.parseInt(scanner.nextLine()), score,
  8.                 volleyballGames = 0, tennisGames = 0, badmintonGames = 0;
  9.         double volleyballScores = 0, tennisScores = 0, badmintonScores = 0;
  10.  
  11.         for (int i = 0; i < games; i++) {
  12.             game = scanner.nextLine();
  13.             score = Integer.parseInt(scanner.nextLine());
  14.  
  15.             if (game.equals("volleyball")) {
  16.                 volleyballGames++;
  17.                 volleyballScores += score * 1.07;
  18.             } else if (game.equals("tennis")) {
  19.                 tennisGames++;
  20.                 tennisScores += score * 1.05;
  21.             } else {
  22.                 badmintonGames++;
  23.                 badmintonScores += score * 1.02;
  24.             }
  25.         }
  26.  
  27.         int averageVolleyballPoints = (int) (volleyballScores / volleyballGames),
  28.                 averageTennisPoints = (int) (tennisScores / tennisGames),
  29.                 averageBadmintonPoints = (int) (badmintonScores / badmintonGames),
  30.                 totalPoints = (int) (volleyballScores + tennisScores + badmintonScores);
  31.  
  32.         if (averageVolleyballPoints >= 75 && averageTennisPoints >= 75 && averageBadmintonPoints >= 75) {
  33.             System.out.println("Congratulations, " + gamer + "! You won the cruise games with " + totalPoints + " points.");
  34.         } else {
  35.             System.out.println("Sorry, " + gamer + ", you lost. Your points are only " + totalPoints + ".");
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement