Advertisement
veronikaaa86

06. Tournament of Christmas

Jun 24th, 2023
708
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.62 KB | None | 0 0
  1. package examPrep;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P06TournamentOfChristmas {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         int days = Integer.parseInt(scanner.nextLine());
  10.  
  11.         double totalProfit = 0;
  12.         int totalWinGameCount = 0;
  13.         int totalLostGameCount = 0;
  14.         for (int i = 1; i <= days; i++) {
  15.             double dayProfit = 0;
  16.             int dayWinGameCount = 0;
  17.             int dayLostGameCount = 0;
  18.  
  19.             String input = scanner.nextLine();
  20.             while (!input.equals("Finish")) {
  21.                 String sport = input;
  22.                 String gamerResult = scanner.nextLine();
  23.  
  24.                 if (gamerResult.equals("win")) {
  25.                     dayProfit = dayProfit + 20;
  26.                     dayWinGameCount++;
  27.                 } else {
  28.                     dayLostGameCount++;
  29.                 }
  30.  
  31.                 input = scanner.nextLine();
  32.             }
  33.             if (dayWinGameCount > dayLostGameCount) {
  34.                 dayProfit = dayProfit * 1.10;
  35.             }
  36.  
  37.             totalProfit = totalProfit + dayProfit;
  38.  
  39.             totalWinGameCount = totalWinGameCount + dayWinGameCount;
  40.             totalLostGameCount = totalLostGameCount + dayLostGameCount;
  41.         }
  42.  
  43.         if (totalWinGameCount > totalLostGameCount) {
  44.             System.out.print("You won the tournament! ");
  45.             totalProfit = totalProfit * 1.20;
  46.         } else {
  47.             System.out.print("You lost the tournament! ");
  48.         }
  49.  
  50.         System.out.printf("Total raised money: %.2f%n", totalProfit);
  51.     }
  52. }
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement