Advertisement
Deiancom

FishingBoat

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