Advertisement
Guest User

06.ExamTournamentofChristmas

a guest
Mar 31st, 2020
526
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. package Exam01.Exam05;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class ExamTournamentofChristmas {
  6. public static void main (String[] args) {
  7. Scanner scanner = new Scanner (System.in);
  8. int days = Integer.parseInt (scanner.nextLine ());
  9. boolean win = false;
  10. boolean winT = false;
  11. double prize = 0;
  12. for (int i = 1; i <= days; i++) {
  13. String event = scanner.nextLine ();
  14. double prizeForDay = 0.0;
  15. while (!event.equals ("Finish")) {
  16. String result = scanner.nextLine ();
  17. if (result.equals ("win")) {
  18. win = true;
  19. prizeForDay += 20;
  20. } else if (result.equals ("lose")) {
  21. win = false;
  22. } else if (result.equals ("Finish")) {
  23. break;
  24. }
  25. }
  26. if (win) {
  27. prize += prizeForDay * 1.1;
  28. winT = true;
  29. } else {
  30. prize += prizeForDay;
  31. winT = false;
  32. }
  33. }
  34. if (!winT) {
  35. System.out.printf ("You lost the tournament! Total raised money: %.2f",prize);
  36. } else {
  37. System.out.printf ("You won the tournament! Total raised money: %.2f",prize * 1.2);
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement