Advertisement
dekploy

Untitled

Jan 28th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 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. int budjet = Integer.parseInt(scanner.nextLine());
  7. String season = scanner.nextLine();
  8. int coutFishers = Integer.parseInt(scanner.nextLine());
  9.  
  10. double discount = 0;
  11.  
  12. switch (season) {
  13. case "Spring":
  14. if (coutFishers <= 6) {
  15. discount = 3000 - (3000 * 0.1);
  16. if (coutFishers % 2 == 0) {
  17. discount = discount - (discount * 0.05);
  18. }
  19. } else if (coutFishers <= 11) {
  20. discount = 3000 - (3000 * 0.15);
  21. if (coutFishers % 2 == 0) {
  22. discount = discount - (discount * 0.05);
  23. }
  24. } else {
  25. discount = 3000 - (3000 * 0.25);
  26. if (coutFishers % 2 == 0) {
  27. discount = discount - (discount * 0.05);
  28. }
  29. }
  30. break;
  31. case "Summer":
  32. case "Autumn":
  33. if (coutFishers <= 6) {
  34. discount = 4200 - (4200 * 0.1);
  35. if ((coutFishers % 2 == 0) && ("Summer".equals(season))) {
  36. discount = discount - (discount * 0.05);
  37. }
  38. } else if (coutFishers <= 11) {
  39. discount = 4200 - (4200 * 0.15);
  40. if ((coutFishers % 2 == 0) && ("Summer".equals(season))) {
  41. discount = discount - (discount * 0.05);
  42. }
  43. } else {
  44. discount = 4200 - (4200 * 0.25);
  45. if ((coutFishers % 2 == 0) && ("Summer".equals(season))) {
  46. discount = discount - (discount * 0.05);
  47. }
  48. }
  49. break;
  50. case "Winter":
  51. if (coutFishers <= 6) {
  52. discount = 2600 - (2600 * 0.1);
  53. if (coutFishers % 2 == 0) {
  54. discount = discount - (discount * 0.05);
  55. }
  56. } else if (coutFishers <= 11) {
  57. discount = 2600 - (2600 * 0.15);
  58. if (coutFishers % 2 == 0) {
  59. discount = discount - (discount * 0.05);
  60. }
  61. } else {
  62. discount = 2600 - (2600 * 0.25);
  63. if (coutFishers % 2 == 0) {
  64. discount = discount - (discount * 0.05);
  65. }
  66. }
  67. break;
  68. }
  69. if (discount <= budjet){
  70. System.out.printf("Yes! You have %.2f leva left.", (budjet - discount));
  71. } else {
  72. System.out.printf("Not enough money! You need %.2f leva.", (discount - budjet));
  73. }
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement