Advertisement
SvetlanPetrova

Fishing Boat SoftUni

Apr 15th, 2021
1,342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.23 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.         int budget = Integer.parseInt(scanner.nextLine());
  7.         String season = scanner.nextLine();
  8.         int fishermenCount = Integer.parseInt(scanner.nextLine());
  9.  
  10.         double shipCost = 0;
  11.         double finalCost = 0;
  12.  
  13.         switch (season) {
  14.             case "Spring":
  15.                 if (fishermenCount <= 6) {
  16.                     shipCost = 3000 * 0.90;
  17.                 }
  18.                 else if (fishermenCount >= 7 && fishermenCount <= 11) {
  19.                     shipCost = 3000 * 0.85;
  20.                 }
  21.                 else if (fishermenCount >= 12) {
  22.                     shipCost = 3000 * 0.75;
  23.                 }
  24.                 break;
  25.             case "Summer":
  26.             case "Autumn":
  27.                 if (fishermenCount <= 6) {
  28.                     shipCost = 4200 * 0.90;
  29.                 }
  30.                 else if (fishermenCount >= 7 && fishermenCount <= 11) {
  31.                     shipCost = 4200 * 0.85;
  32.                 }
  33.                 else if (fishermenCount >= 12) {
  34.                     shipCost = 4200 * 0.75;
  35.                 }
  36.                 break;
  37.             case "Winter":
  38.                 if (fishermenCount <= 6) {
  39.                     shipCost = 2600 * 0.90;
  40.                 }
  41.                 else if (fishermenCount >= 7 && fishermenCount <= 11) {
  42.                     shipCost = 2600 * 0.85;
  43.                 }
  44.                 else if (fishermenCount >= 12) {
  45.                     shipCost = 2600 * 0.75;
  46.                 }
  47.                 break;
  48.         }
  49.  
  50.         if (!season.equals("Autumn")) {
  51.             if (fishermenCount % 2 == 0) {
  52.                 finalCost = shipCost * 0.95;
  53.             }
  54.             else {
  55.                 finalCost = shipCost;
  56.             }
  57.         }
  58.         else if (season.equals("Autumn")) {
  59.            finalCost = shipCost;
  60.         }
  61.  
  62.         if (budget >= finalCost) {
  63.             System.out.printf("Yes! You have %.2f leva left.", budget - finalCost);
  64.         }
  65.         else {
  66.             System.out.printf("Not enough money! You need %.2f leva.", finalCost - budget);
  67.         }
  68.  
  69.     }
  70. }
  71.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement