Advertisement
myrdok123

Untitled

Feb 17th, 2023
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1.  
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Demo {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9.  
  10. int countDays = Integer.parseInt(scanner.nextLine());
  11.  
  12.  
  13. double allMoney = 0;
  14. double countWinsDays = 0;
  15. double countLosesDays = 0;
  16.  
  17.  
  18. for (int i = 1; i <= countDays; i++) {
  19. double moneyPerDay = 0;
  20. double percent = 0;
  21. double countWinsPerDay = 0;
  22. double countLosesPerDay = 0;
  23. String input = scanner.nextLine();
  24. while (!input.equals("Finish")) {
  25.  
  26.  
  27. String ranking = scanner.nextLine();
  28. if (ranking.equals("win")) {
  29. countWinsPerDay++;
  30. } else if (ranking.equals("lose")) {
  31. countLosesPerDay++;
  32. }
  33.  
  34. input = scanner.nextLine();
  35. }
  36. moneyPerDay = countWinsPerDay * 20;
  37. countWinsDays += countWinsPerDay;
  38. countLosesDays += countLosesPerDay;
  39.  
  40. if (countWinsPerDay > countLosesPerDay) {
  41. percent = moneyPerDay * 0.90;
  42. allMoney += (moneyPerDay - percent) + moneyPerDay;
  43.  
  44. } else {
  45. allMoney += moneyPerDay;
  46.  
  47. }
  48.  
  49. }
  50.  
  51. if (countWinsDays > countLosesDays) {
  52. double finalSum = allMoney * 1.2;
  53. System.out.printf("You won the tournament! Total raised money: %.2f", finalSum);
  54. } else {
  55. System.out.printf("You lost the tournament! Total raised money: %.2f", allMoney);
  56. }
  57.  
  58. }
  59. }
  60.  
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement