Advertisement
tripTiPscout

Tournament of Christmas

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