Advertisement
mark79

Fishing Boat

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