Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class TournamentOfChristmas_06 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int days = Integer.parseInt(scanner.nextLine());
- double totalSum = 0;
- int daysWin = 0;
- int daysLose = 0;
- for (int day = 1; day <= days; day++) {
- int countWins = 0;
- int countLoses = 0;
- double sumPerDay = 0;
- String game = scanner.nextLine();
- while (!game.equals("Finish")) {
- String result = scanner.nextLine();
- if (result.equals("win")) {
- countWins++;
- sumPerDay += 20;
- } else if (result.equals("lose")) {
- countLoses++;
- }
- game = scanner.nextLine();
- }
- if (countWins > countLoses) {
- sumPerDay += sumPerDay * 0.1;
- daysWin++;
- } else {
- daysLose++;
- }
- totalSum += sumPerDay;
- }
- if (daysWin > daysLose) {
- totalSum += totalSum * 0.2;
- System.out.printf("You won the tournament! Total raised money: %.2f", totalSum);
- } else {
- System.out.printf("You lost the tournament! Total raised money: %.2f", totalSum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement