Advertisement
uktcar

03.2.04FishingBoat

Mar 16th, 2023 (edited)
612
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.57 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ex04FishingBoat {
  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 peoples = Integer.parseInt(scanner.nextLine());
  10.  
  11.         double price = 0;
  12.  
  13.         if (season.equals("Spring")) {
  14.             price = 3000;
  15.             if (peoples <= 6) {
  16.                 price *= 0.9;
  17.             } else if (peoples <= 11) {
  18.                 price *= 0.85;
  19.             } else {
  20.                 price *= 0.75;
  21.             }
  22.         } else if (season.equals("Summer") || season.equals("Autumn")) {
  23.             price = 4200;
  24.             if (peoples <= 6) {
  25.                 price *= 0.9;
  26.             } else if (peoples <= 11) {
  27.                 price *= 0.85;
  28.             } else {
  29.                 price *= 0.75;
  30.             }
  31.         } else if (season.equals("Winter")) {
  32.             price = 2600;
  33.             if (peoples <= 6) {
  34.                 price *= 0.9;
  35.             } else if (peoples <= 11) {
  36.                 price *= 0.85;
  37.             } else {
  38.                 price *= 0.75;
  39.             }
  40.         }
  41.  
  42.         if (peoples % 2 == 0 && !season.equals("Autumn")) {
  43.             price *= 0.95;
  44.         }
  45.  
  46.         double diff = Math.abs(budget - price);
  47.  
  48.         if (budget >= price) {
  49.             System.out.printf("Yes! You have %.2f leva left.", diff);
  50.         } else {
  51.             System.out.printf("Not enough money! You need %.2f leva.", diff);
  52.         }
  53.     }
  54. }
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement