Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Exam01.Exam05;
- import java.util.Scanner;
- public class ExamTournamentofChristmas {
- public static void main (String[] args) {
- Scanner scanner = new Scanner (System.in);
- int days = Integer.parseInt (scanner.nextLine ());
- boolean win = false;
- boolean winT = false;
- double prize = 0;
- for (int i = 1; i <= days; i++) {
- String event = scanner.nextLine ();
- double prizeForDay = 0.0;
- while (!event.equals ("Finish")) {
- String result = scanner.nextLine ();
- if (result.equals ("win")) {
- win = true;
- prizeForDay += 20;
- } else if (result.equals ("lose")) {
- win = false;
- } else if (result.equals ("Finish")) {
- break;
- }
- }
- if (win) {
- prize += prizeForDay * 1.1;
- winT = true;
- } else {
- prize += prizeForDay;
- winT = false;
- }
- }
- if (!winT) {
- System.out.printf ("You lost the tournament! Total raised money: %.2f",prize);
- } else {
- System.out.printf ("You won the tournament! Total raised money: %.2f",prize * 1.2);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement