Advertisement
Spocoman

Tournament of Christmas

Sep 10th, 2024 (edited)
402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.31 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.         int days = Integer.parseInt(scanner.nextLine()),
  7.                 winTotal = 0, loseTotal = 0;
  8.         double totalSum = 0;
  9.         String command;
  10.  
  11.         for (int i = 0; i < days; i++) {
  12.             int win = 0, lose = 0;
  13.             double sum = 0;
  14.  
  15.             while (true) {
  16.                 command = scanner.nextLine();
  17.                 if (command.equals("win")) {
  18.                     sum += 20;
  19.                     win++;
  20.                 } else if (command.equals("lose")) {
  21.                     lose++;
  22.                 } else if (command.equals("Finish")) {
  23.                     if (win > lose) {
  24.                         totalSum += sum * 1.1;
  25.                         winTotal += win;
  26.                     } else {
  27.                         totalSum += sum;
  28.                         loseTotal += lose;
  29.                     }
  30.                     break;
  31.                 }
  32.             }
  33.         }
  34.  
  35.         if (winTotal > loseTotal) {
  36.             System.out.printf("You won the tournament! Total raised money: %.2f\n", totalSum * 1.2);
  37.         } else {
  38.             System.out.printf("You lost the tournament! Total raised money: %.2f\n", totalSum);
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement