desislava_topuzakova

Untitled

Mar 14th, 2022
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.69 KB | None | 0 0
  1. package advancedConditionalStatementsExercise;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P04FishingBoat {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. int budget = Integer.parseInt(scanner.nextLine());
  10. String season = scanner.nextLine();
  11. int fishermen = Integer.parseInt(scanner.nextLine());
  12. double priceBoat;
  13. double priceBoatDiscount = 0;
  14. double difference;
  15. boolean isEvenNumber = fishermen % 2 == 0;
  16.  
  17. if (season.equals("Spring")) {
  18. if (isEvenNumber) {
  19. if (fishermen <= 6) {
  20. priceBoat = 3000 - (3000 * 0.10);
  21. priceBoatDiscount = priceBoat - (priceBoat * 0.05);
  22. } else if (fishermen >= 7 && fishermen <= 11) {
  23. priceBoat = 3000 - (3000 * 0.15);
  24. priceBoatDiscount = priceBoat - (priceBoat * 0.05);
  25. } else if (fishermen >= 12) {
  26. priceBoat = 3000 - (3000 * 0.25);
  27. priceBoatDiscount = priceBoat - (priceBoat * 0.05);
  28. }
  29.  
  30. } else if (fishermen <= 6) {
  31. priceBoat = (int) (3000 - (3000 * 0.10));
  32. priceBoatDiscount = priceBoat;
  33. } else if (fishermen >= 7 && fishermen <= 11) {
  34. priceBoat = (int) (3000 - (3000 * 0.15));
  35. priceBoatDiscount = priceBoat;
  36. } else if (fishermen >= 12) {
  37. priceBoat = (int) (3000 - (3000 * 0.25));
  38. priceBoatDiscount = priceBoat;
  39. }
  40.  
  41.  
  42.  
  43. } else if (season.equals("Summer")) {
  44. if (isEvenNumber) {
  45. if (fishermen <= 6) {
  46. priceBoat = 4200 - (4200 * 0.10);
  47. priceBoatDiscount = priceBoat - (priceBoat * 0.05);
  48. } else if (fishermen >= 7 && fishermen <= 11) {
  49. priceBoat = 4200 - (4200 * 0.15);
  50. priceBoatDiscount = priceBoat - (priceBoat * 0.05);
  51. } else if (fishermen >= 12) {
  52. priceBoat = 4200 - (4200 * 0.25);
  53. priceBoatDiscount = priceBoat - (priceBoat * 0.05);
  54. }
  55.  
  56. } else if (fishermen <= 6) {
  57. priceBoat = 4200 - (4200 * 0.10);
  58. priceBoatDiscount = priceBoat;
  59. } else if (fishermen >= 7 && fishermen <= 11) {
  60. priceBoat = 4200 - (4200 * 0.15);
  61. priceBoatDiscount = priceBoat;
  62. } else if (fishermen >= 12) {
  63. priceBoat = 4200 - (4200 * 0.25);
  64. priceBoatDiscount = priceBoat;
  65. }
  66.  
  67.  
  68. } else if (season.equals("Autumn")) {
  69. if (fishermen <= 6) {
  70. priceBoat = (int) (4200 - (4200 * 0.10));
  71. priceBoatDiscount = priceBoat;
  72. } else if (fishermen >= 7 && fishermen <= 11) {
  73. priceBoat = (int) (4200 - (4200 * 0.15));
  74. priceBoatDiscount = priceBoat;
  75. } else if (fishermen >= 12) {
  76. priceBoat = (int) (4200 - (4200 * 0.25));
  77. priceBoatDiscount = priceBoat;
  78. }
  79.  
  80.  
  81. } else if (season.equals("Winter")) {
  82. if (isEvenNumber) {
  83. if (fishermen <= 6) {
  84. priceBoat = (int) (2600 - (2600 * 0.10));
  85. priceBoatDiscount = priceBoat - (priceBoat * 0.05);
  86. } else if (fishermen >= 7 && fishermen <= 11) {
  87. priceBoat = (int) (2600 - (2600 * 0.15));
  88. priceBoatDiscount = priceBoat - (priceBoat * 0.05);
  89. } else if (fishermen >= 12) {
  90. priceBoat = (int) (2600 - (2600 * 0.25));
  91. priceBoatDiscount = priceBoat - (priceBoat * 0.05);
  92. }
  93.  
  94. } else if (fishermen <= 6) {
  95. priceBoat = (int) (2600 - (2600 * 0.10));
  96. priceBoatDiscount = priceBoat;
  97. } else if (fishermen >= 7 && fishermen <= 11) {
  98. priceBoat = (int) (2600 - (2600 * 0.15));
  99. priceBoatDiscount = priceBoat;
  100. } else if (fishermen >= 12) {
  101. priceBoat = (int) (2600 - (2600 * 0.25));
  102. priceBoatDiscount = priceBoat;
  103. }
  104. }
  105.  
  106.  
  107. difference = budget - priceBoatDiscount;
  108. if (difference >= 0) {
  109. difference = Math.abs(difference);
  110. System.out.printf("Yes! You have %.2f leva left.", difference);
  111. } else {
  112. difference = Math.abs(difference);
  113. System.out.printf("Not enough money! You need %.2f leva.", difference);
  114. }
  115.  
  116. }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment