Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. package exercise3;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class FishingBoat {
  6.  
  7. public static void main(String[] args) {
  8. Scanner scanner = new Scanner(System.in);
  9.  
  10. double budget = Double.parseDouble(scanner.nextLine());
  11. String season = scanner.nextLine();
  12. int fisherman = Integer.parseInt(scanner.nextLine());
  13. double discount = 0;
  14. double total = 0;
  15.  
  16. if (fisherman <= 6) {
  17. if (season.equalsIgnoreCase("Spring")) {
  18. discount = 3000 * 0.10;
  19. total = 3000 - discount;
  20. } else if ((season.equalsIgnoreCase("Summer")) || (season.equalsIgnoreCase("Autumn"))) {
  21. discount = 4200 * 0.10;
  22. total = 4200 - discount;
  23. } else if (season.equalsIgnoreCase("Winter")) {
  24. discount = 2600 * 0.10;
  25. total = 2600 - discount;
  26. }
  27. } else if ((fisherman >= 7) && (fisherman <= 11)) {
  28. if (season.equalsIgnoreCase("Spring")) {
  29. discount = 3000 * 0.15;
  30. total = 3000 - discount;
  31. } else if ((season.equalsIgnoreCase("Summer")) || (season.equalsIgnoreCase("Autumn"))) {
  32. discount = 4200 * 0.15;
  33. total = 4200 - discount;
  34. } else if (season.equalsIgnoreCase("Winter")) {
  35. discount = 2600 * 0.15;
  36. total = 2600 - discount;
  37. }
  38. } else if (fisherman >= 12) {
  39. if (season.equalsIgnoreCase("Spring")) {
  40. discount = 3000 * 0.25;
  41. total = 3000 - discount;
  42. } else if (season.equalsIgnoreCase(("Summer")) || (season.equalsIgnoreCase("Autumn"))) {
  43. discount = 4200 * 0.25;
  44. total = 4200 - discount;
  45. } else if (season.equalsIgnoreCase("Winter")) {
  46. discount = 2600 * 0.25;
  47. total = 2600 - discount;
  48. }
  49. }
  50.  
  51. if ((fisherman % 2 == 0) && (!season.equalsIgnoreCase("Autumn"))) {
  52. discount = total * 0.05;
  53. total = total - discount;
  54. } else {
  55. total = total;
  56. }
  57.  
  58. double difference = 0;
  59.  
  60. if (budget > total) {
  61. difference = budget - total;
  62. System.out.printf("Yes! You have %.2f leva left.", difference);
  63. } else if (total > budget) {
  64. difference = total - budget;
  65. System.out.printf("Not enough money! You need %.2f leva.", difference);
  66. }
  67.  
  68. }
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement