Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Tournament_06 {
- public static void main(String[] args) {
- Scanner myScan = new Scanner(System.in);
- int days = Integer.parseInt(myScan.nextLine());
- String game = "";
- String result = "";
- int winnerCount = 0;
- int loserCount = 0;
- int totalWinCount = 0;
- int totalLossCount = 0;
- double raisedMoneyPerDay = 0;
- double raisedMoney = 0;
- boolean isFinal = false;
- for (int i = 1; i <= days; i++) {
- isFinal = false;
- while (!isFinal) {
- game = myScan.nextLine();
- if (game.equals("Finish")) {
- isFinal = true;
- break;
- }
- result = myScan.nextLine();
- if (result.equals("win")) {
- winnerCount++;
- raisedMoneyPerDay += 20;
- } else if (result.equals("lose")) {
- loserCount++;
- }
- }
- if (winnerCount > loserCount) {
- raisedMoney += raisedMoneyPerDay * 1.10;
- } else {
- raisedMoney += raisedMoneyPerDay;
- }
- raisedMoneyPerDay = 0;
- totalLossCount += loserCount;
- totalWinCount += winnerCount;
- winnerCount = 0;
- loserCount = 0;
- }
- if(totalWinCount > totalLossCount) {
- System.out.printf("You won the tournament! Total raised money: %.2f", (raisedMoney * 1.20));
- } else {
- System.out.printf("You lost the tournament! Total raised money: %.2f", raisedMoney);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment