Advertisement
Lyubohd

Tournament of Christmas

Apr 26th, 2020
465
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.42 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class TournamentOfChristmas_06 {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.  
  7.         int days = Integer.parseInt(scan.nextLine());
  8.         double totalSum = 0;
  9.         int daysWin = 0;
  10.         int daysLose = 0;
  11.  
  12.         for (int day = 1; day <= days; day++) {
  13.             int countWins = 0;
  14.             int countLoses = 0;
  15.             double sumPerDay = 0;
  16.             String game = scan.nextLine();
  17.             while (!"Finish".equals(game)) {
  18.                 String result = scan.nextLine();
  19.  
  20.                 if ("win".equals(result)) {
  21.                     countWins++;
  22.                     sumPerDay += 20;
  23.                 } else if ("lose".equals(result)) {
  24.                     countLoses++;
  25.                 }
  26.  
  27.                 game = scan.nextLine();
  28.             }
  29.  
  30.             if (countWins > countLoses) {
  31.                 sumPerDay = sumPerDay + sumPerDay * 0.1;
  32.                 daysWin++;
  33.  
  34.             } else {
  35.                 daysLose++;
  36.             }
  37.  
  38.             totalSum = totalSum + sumPerDay;
  39.         }
  40.  
  41.         if (daysWin > daysLose) {
  42.             totalSum = totalSum + totalSum * 0.2;
  43.             System.out.printf("You won the tournament! Total raised money: %.2f", totalSum);
  44.         } else {
  45.             System.out.printf("You lost the tournament! Total raised money: %.2f", totalSum);
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement