Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int days = Integer.parseInt(scanner.nextLine()),
- winTotal = 0, loseTotal = 0;
- double totalSum = 0;
- String command;
- for (int i = 0; i < days; i++) {
- int win = 0, lose = 0;
- double sum = 0;
- while (true) {
- command = scanner.nextLine();
- if (command.equals("Finish")) {
- if (win > lose) {
- totalSum += sum * 1.1;
- winTotal += win;
- } else {
- totalSum += sum;
- loseTotal += lose;
- }
- break;
- }
- if (command.equals("win")) {
- sum += 20;
- win++;
- } else if (command.equals("lose")) {
- lose++;
- }
- }
- }
- if (winTotal > loseTotal) {
- System.out.printf("You won the tournament! Total raised money: %.2f\n", totalSum * 1.2);
- } else {
- System.out.printf("You lost the tournament! Total raised money: %.2f\n", totalSum);
- }
- }
- }
- ИЛИ:
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int days = Integer.parseInt(scanner.nextLine()),
- winTotal = 0, loseTotal = 0;
- double totalSum = 0;
- String command;
- for (int i = 0; i < days; i++) {
- int win = 0, lose = 0;
- double sum = 0;
- label:
- while (true) {
- command = scanner.nextLine();
- switch (command) {
- case "Finish":
- if (win > lose) {
- totalSum += sum * 1.1;
- winTotal += win;
- } else {
- totalSum += sum;
- loseTotal += lose;
- }
- break label;
- case "win":
- sum += 20;
- win++;
- break;
- case "lose":
- lose++;
- break;
- }
- }
- }
- if (winTotal > loseTotal) {
- System.out.printf("You won the tournament! Total raised money: %.2f\n", totalSum * 1.2);
- } else {
- System.out.printf("You lost the tournament! Total raised money: %.2f\n", totalSum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement