Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package examPrep;
- import java.util.Scanner;
- public class P06TournamentOfChristmas {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int days = Integer.parseInt(scanner.nextLine());
- double totalProfit = 0;
- int totalWinGameCount = 0;
- int totalLostGameCount = 0;
- for (int i = 1; i <= days; i++) {
- double dayProfit = 0;
- int dayWinGameCount = 0;
- int dayLostGameCount = 0;
- String input = scanner.nextLine();
- while (!input.equals("Finish")) {
- String sport = input;
- String gamerResult = scanner.nextLine();
- if (gamerResult.equals("win")) {
- dayProfit = dayProfit + 20;
- dayWinGameCount++;
- } else {
- dayLostGameCount++;
- }
- input = scanner.nextLine();
- }
- if (dayWinGameCount > dayLostGameCount) {
- dayProfit = dayProfit * 1.10;
- }
- totalProfit = totalProfit + dayProfit;
- totalWinGameCount = totalWinGameCount + dayWinGameCount;
- totalLostGameCount = totalLostGameCount + dayLostGameCount;
- }
- if (totalWinGameCount > totalLostGameCount) {
- System.out.print("You won the tournament! ");
- totalProfit = totalProfit * 1.20;
- } else {
- System.out.print("You lost the tournament! ");
- }
- System.out.printf("Total raised money: %.2f%n", totalProfit);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement