raliportokali

Untitled

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