desislava_topuzakova

Edit Fish Boat

Mar 15th, 2022
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. package ConditionalStatementsAdvancedExercises;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class FishingBoat {
  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.  
  13. double shipRent = 0;
  14.  
  15. switch (season) {
  16. case "Spring":
  17. shipRent = 3000;
  18. break;
  19. case "Summer":
  20. case "Autumn":
  21. shipRent = 4200;
  22. break;
  23. case "Winter":
  24. shipRent = 2600;
  25. default:
  26. break;
  27. }
  28.  
  29. if (fisherMen <= 6 ) {
  30. shipRent = shipRent - shipRent * 0.10;
  31. } else if (fisherMen >= 7 && fisherMen <= 11) {
  32. shipRent = shipRent - shipRent * 0.15;
  33. } else if (fisherMen >= 12) {
  34. shipRent = shipRent - shipRent * 0.25;
  35. }
  36.  
  37. if (fisherMen % 2 == 0 && !season.equals("Autumn")) {
  38. shipRent = shipRent - shipRent * 0.05;
  39. }
  40. if (budget >= shipRent) {
  41. System.out.printf("Yes! You have %.2f leva left.", budget - shipRent);
  42. } else {
  43. System.out.printf("Not enough money! You need %.2f leva.", shipRent - budget);
  44.  
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment