Advertisement
Guest User

Untitled

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