desislava_topuzakova

06. Tournament of Christmas

Mar 31st, 2020
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.40 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class TournamentOfChristmas_06 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int days = Integer.parseInt(scanner.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 = scanner.nextLine();
  17.             while (!game.equals("Finish")) {
  18.                 String result = scanner.nextLine();
  19.  
  20.                 if (result.equals("win")) {
  21.                     countWins++;
  22.                     sumPerDay += 20;
  23.                 } else if (result.equals("lose")) {
  24.                     countLoses++;
  25.                 }
  26.  
  27.                 game = scanner.nextLine();
  28.             }
  29.  
  30.             if (countWins > countLoses) {
  31.                 sumPerDay += sumPerDay * 0.1;
  32.                 daysWin++;
  33.  
  34.             } else {
  35.                 daysLose++;
  36.             }
  37.  
  38.             totalSum += sumPerDay;
  39.         }
  40.  
  41.         if (daysWin > daysLose) {
  42.             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. }
Add Comment
Please, Sign In to add comment