Advertisement
Guest User

Untitled

a guest
Sep 30th, 2019
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class FishingBoat {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int budget = Integer.parseInt(scanner.nextLine());
  8. String season = scanner.nextLine();
  9. int countFishers = Integer.parseInt(scanner.nextLine());
  10.  
  11. double totalPrice = 0;
  12.  
  13. if ("Spring".equals(season)) {
  14. if (countFishers <= 6) {
  15. totalPrice = 3000 * 0.9;
  16.  
  17. } else if (countFishers % 2 == 0) {
  18. totalPrice = (3000 * 0.9) - 3000*0.05;
  19. }
  20. if (countFishers >= 7 && countFishers <= 11) {
  21. totalPrice = 3000 * 0.85;
  22. } else if (countFishers % 2 == 0) {
  23. totalPrice = (3000 * 0.85) - 3000*0.05;
  24. }
  25. if (countFishers >= 12) {
  26. totalPrice = 3000 * 0.75;
  27. } else if (countFishers % 2 == 0) {
  28. totalPrice = (3000 * 0.75) - 3000*0.05;
  29. }
  30.  
  31. } else if ("Summer".equals(season)) {
  32. if (countFishers <= 6) {
  33. totalPrice = 4200 * 0.9;
  34.  
  35. } else if (countFishers % 2 == 0) {
  36. totalPrice = (4200 * 0.9) - 4200*0.05;
  37. }
  38. if (countFishers >= 7 && countFishers <= 11) {
  39. totalPrice = 4200 * 0.85;
  40. } else if (countFishers % 2 == 0) {
  41. totalPrice = (4200 * 0.85) - 4200*0.05;
  42. }
  43. if (countFishers >= 12) {
  44. totalPrice = 4200 * 0.75;
  45. } else if (countFishers % 2 == 0) {
  46. totalPrice = (4200 * 0.75) - 4200*0.05;
  47. }
  48.  
  49. } else if ("Autumn".equals(season)) {
  50. if (countFishers <= 6) {
  51. totalPrice = 4200 * 0.9;
  52. } else if (countFishers <= 11) {
  53. totalPrice = 4200 * 0.85;
  54. } else {
  55. totalPrice = 4200 * 0.75;
  56. }
  57.  
  58. } else if ("Winter".equals(season)) {
  59. if (countFishers <= 6) {
  60. totalPrice = 2600 * 0.9;
  61.  
  62. } else if (countFishers % 2 == 0) {
  63. totalPrice = (2600 * 0.9) - 2600*0.05;
  64. }
  65. if (countFishers >= 7 && countFishers <= 11) {
  66. totalPrice = 2600 * 0.85;
  67. } else if (countFishers % 2 == 0) {
  68. totalPrice = (2600 * 0.85) - 2600*0.05;
  69. }
  70. if (countFishers >= 12) {
  71. totalPrice = 2600 * 0.75;
  72. } else if (countFishers % 2 == 0) {
  73. totalPrice = (2600 * 0.75) - 2600*0.05;
  74. }
  75. }
  76. double diff = 0;
  77. if (budget >= totalPrice) {
  78. diff = budget - totalPrice;
  79. System.out.printf("Yes! You have %.2f leva left.", diff);
  80. } else {
  81. diff = totalPrice - budget;
  82. System.out.printf("Not enough money! You need %.2f leva.", diff);
  83. }
  84. }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement