Advertisement
desislava_topuzakova

04. Fishing Boat

Jul 31st, 2024
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. package ExsWeek_03;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class FishingBoat {
  6. public static void main (String [] args){
  7.  
  8. Scanner scanner = new Scanner(System.in);
  9.  
  10. int budget = Integer.parseInt(scanner.nextLine());
  11. String season = scanner.nextLine();
  12. int fisherman = Integer.parseInt(scanner.nextLine());
  13.  
  14. double priceForSeason = 0;
  15.  
  16. switch (season) {
  17. case "Spring":
  18. priceForSeason = 3000;
  19. break;
  20.  
  21. case "Summer":
  22. case "Autumn":
  23. priceForSeason = 4200;
  24. break;
  25.  
  26. case "Winter":
  27. priceForSeason = 2600;
  28. break;
  29. }
  30. //double discount = 0;
  31.  
  32. if (fisherman <= 6){
  33. priceForSeason = priceForSeason - priceForSeason * 0.10;
  34. } else if ( fisherman <= 11){
  35. priceForSeason = priceForSeason - priceForSeason * 0.15;
  36. } else if (fisherman >= 15){
  37. priceForSeason = priceForSeason - priceForSeason * 0.25;
  38. }
  39.  
  40. if (fisherman % 2 == 0 && !season.equals("Autumn")){
  41. priceForSeason = priceForSeason * 0.95;
  42. }
  43.  
  44. if (budget >= priceForSeason){
  45. System.out.printf("Yes! You have %.2f leva left.",budget - priceForSeason);
  46. }else if (priceForSeason > budget){
  47. System.out.printf("Not enough money! You need %.2f leva.", priceForSeason - budget);
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement