Advertisement
CR7CR7

Tournament

Feb 25th, 2023
770
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.58 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class TournamentsSwitch {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int days = Integer.parseInt(scanner.nextLine());
  8.  
  9.         int totalWinsCount = 0;
  10.         int totalLosesCount = 0;
  11.         double totalRaisedMoney = 0;
  12.  
  13.         for (int i = 1; i <= days; i++) {
  14.             String command = scanner.nextLine();
  15.  
  16.             int winsCount = 0;
  17.             int losesCount = 0;
  18.             double raisedMoney = 0;
  19.  
  20.             while (!command.equals("Finish")) {
  21.                 String sport = command;
  22.                 String result = scanner.nextLine();
  23.  
  24.                 switch (result) {
  25.                     case "win":
  26.                         winsCount++;
  27.                         raisedMoney += 20;
  28.                         break;
  29.                     case "lose":
  30.                         losesCount++;
  31.                         break;
  32.                 }
  33.  
  34.                 command = scanner.nextLine();
  35.             }
  36.  
  37.             if (winsCount > losesCount) {
  38.                 raisedMoney *= 1.1;
  39.             }
  40.  
  41.             totalWinsCount += winsCount;
  42.             totalLosesCount += losesCount;
  43.             totalRaisedMoney += raisedMoney;
  44.  
  45.         }
  46.  
  47.         if (totalWinsCount > totalLosesCount) {
  48.             totalRaisedMoney *= 1.2;
  49.             System.out.printf("You won the tournament! Total raised money: %.2f", totalRaisedMoney);
  50.         } else {
  51.             System.out.printf("You lost the tournament! Total raised money: %.2f", totalRaisedMoney);
  52.         }
  53.  
  54.     }
  55. }
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement