Advertisement
veronikaaa86

06. Tournament of Christmas

Jun 19th, 2021
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. package examPrep;
  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. int winCounter = 0;
  12. int loseCounter = 0;
  13. double allSum = 0;
  14. for (int i = 1; i <= days; i++) {
  15.  
  16. int dayWinCounter = 0;
  17. int dayLoseCounter = 0;
  18. String input = scanner.nextLine();
  19. while (!input.equals("Finish")) {
  20. // String sport = input;
  21. String status = scanner.nextLine();
  22.  
  23. if (status.equals("win")) {
  24. dayWinCounter++;
  25. winCounter++;
  26. } else {
  27. dayLoseCounter++;
  28. loseCounter++;
  29. }
  30.  
  31. input = scanner.nextLine();
  32. }
  33.  
  34. double dayMoney = dayWinCounter * 20;
  35. if (dayWinCounter > dayLoseCounter) {
  36. dayMoney = dayMoney * 1.10;
  37. }
  38.  
  39. allSum = allSum + dayMoney;
  40. }
  41.  
  42. if (winCounter > loseCounter) {
  43. allSum = allSum * 1.20;
  44. System.out.printf("You won the tournament! Total raised money: %.2f", allSum);
  45. } else {
  46. System.out.printf("You lost the tournament! Total raised money: %.2f", allSum);
  47. }
  48. }
  49. }
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement