borovaneca

Tournament Of Christmas

Nov 30th, 2022
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.91 KB | None | 0 0
  1. package PBMore.PBExams;
  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 days = Integer.parseInt(scanner.nextLine());
  10.         String input = "";
  11.         String name = "";
  12.         String winOrLose = "";
  13.         double winedMoney = 0;
  14.         int win = 0;
  15.         int lose = 0;
  16.         int count = 0;
  17.         double money = 0;
  18.         int winedDays = 0;
  19.         int lostDays = 0;
  20.         double wontSum = 0;
  21.  
  22.         for (int i = 1; i <=days; i++) {
  23.  
  24.             win = 0;
  25.             lose = 0;
  26.             money = 0;
  27.             while (!input.equals("Finish")) {
  28.                 count++;
  29.                 if (count > 1) {
  30.                     name = input;
  31.                 } else {
  32.                     name = scanner.nextLine();
  33.                 }
  34.                 winOrLose = scanner.nextLine();
  35.                 switch (winOrLose) {
  36.                     case "win":
  37.                         win++;
  38.                         money += 20;
  39.                         break;
  40.                     case "lose":
  41.                         lose++;
  42.                         break;
  43.                 }
  44.  
  45.                 input = scanner.nextLine();
  46.             }
  47.  
  48.             if (win > lose){
  49.                 money += money * 0.10;
  50.                 winedDays++;
  51.                 wontSum += money;
  52.             } else {
  53.                 lostDays++;
  54.                 wontSum += money;
  55.             }
  56.             if (i == days){
  57.                 break;
  58.             }
  59.             input = scanner.nextLine();
  60.         }
  61.         if (winedDays > lostDays){
  62.             wontSum += wontSum * 0.20;
  63.             System.out.printf("You won the tournament! Total raised money: %.2f", wontSum);
  64.         } else {
  65.             System.out.printf("You lost the tournament! Total raised money: %.2f", wontSum);
  66.         }
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment