veronikaaa86

06. Tournament of Christmas

Apr 9th, 2022 (edited)
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. package examPreparation;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P06TournamentOfChristmas {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. int days = Integer.parseInt(scanner.nextLine());
  10.  
  11. double totalDaysSum = 0;
  12. int totalCountDaysWin = 0;
  13. int totalCountDaysLost = 0;
  14. for (int i = 1; i <= days; i++) {
  15. double dayProfit = 0;
  16.  
  17. int dayCountWin = 0;
  18. int dayCountLost = 0;
  19. String input = scanner.nextLine();
  20. while (!input.equals("Finish")) {
  21. String status = scanner.nextLine();
  22. if (status.equals("win")) {
  23. dayProfit = dayProfit + 20;
  24. dayCountWin++;
  25. } else if (status.equals("lose")) {
  26. dayCountLost++;
  27. }
  28.  
  29. input = scanner.nextLine();
  30. }
  31.  
  32. if (dayCountWin > dayCountLost) {
  33. totalCountDaysWin++;
  34. dayProfit = dayProfit * 1.10;
  35. } else {
  36. totalCountDaysLost++;
  37. }
  38.  
  39. totalDaysSum = totalDaysSum + dayProfit;
  40. }
  41.  
  42. if (totalCountDaysWin > totalCountDaysLost) {
  43. totalDaysSum = totalDaysSum * 1.20;
  44. System.out.print("You won the tournament! ");
  45. System.out.printf("Total raised money: %.2f", totalDaysSum);
  46. } else {
  47. System.out.print("You lost the tournament! ");
  48. System.out.printf("Total raised money: %.2f", totalDaysSum);
  49. }
  50. }
  51. }
  52.  
Add Comment
Please, Sign In to add comment