Advertisement
MladenKarachanov

Untitled

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