stoyanoff

Tournament_06

Jul 22nd, 2020
1,974
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.74 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Tournament_06 {
  6.     public static void main(String[] args) {
  7.         Scanner myScan = new Scanner(System.in);
  8.  
  9.         int days = Integer.parseInt(myScan.nextLine());
  10.         String game = "";
  11.         String result = "";
  12.         int winnerCount = 0;
  13.         int loserCount = 0;
  14.         int totalWinCount = 0;
  15.         int totalLossCount = 0;
  16.         double raisedMoneyPerDay = 0;
  17.         double raisedMoney = 0;
  18.         boolean isFinal = false;
  19.  
  20.         for (int i = 1; i <= days; i++) {
  21.  
  22.             isFinal = false;
  23.             while (!isFinal) {
  24.                 game = myScan.nextLine();
  25.                 if (game.equals("Finish")) {
  26.                     isFinal = true;
  27.                     break;
  28.                 }
  29.                 result = myScan.nextLine();
  30.                 if (result.equals("win")) {
  31.                     winnerCount++;
  32.                     raisedMoneyPerDay += 20;
  33.                 } else if (result.equals("lose")) {
  34.                     loserCount++;
  35.                 }
  36.  
  37.  
  38.             }
  39.             if (winnerCount > loserCount) {
  40.                 raisedMoney += raisedMoneyPerDay * 1.10;
  41.             } else {
  42.                 raisedMoney += raisedMoneyPerDay;
  43.             }
  44.             raisedMoneyPerDay = 0;
  45.             totalLossCount += loserCount;
  46.             totalWinCount += winnerCount;
  47.             winnerCount = 0;
  48.             loserCount = 0;
  49.  
  50.         }
  51.         if(totalWinCount > totalLossCount) {
  52.             System.out.printf("You won the tournament! Total raised money: %.2f", (raisedMoney * 1.20));
  53.         } else {
  54.             System.out.printf("You lost the tournament! Total raised money: %.2f", raisedMoney);
  55.         }
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment