Advertisement
vkarakolev

Untitled

Jul 4th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.45 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class FishingBoat_04 {
  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 fishersCount = Integer.parseInt(scanner.nextLine());
  9.         double boatPrice = 0;
  10.         double discount = 0;
  11.  
  12.         switch (season) {
  13.             case "Spring":
  14.                 boatPrice = 3000;
  15.                 break;
  16.             case "Summer":
  17.             case "Autumn":
  18.                 boatPrice = 4200;
  19.                 break;
  20.             case "Winter":
  21.                 boatPrice = 2600;
  22.                 break;
  23.         }
  24.  
  25.         if (fishersCount <= 6) {
  26.             discount = 0.1 * boatPrice;
  27.         } else if (fishersCount >= 7 && fishersCount <= 11) {
  28.             discount = 0.15 * boatPrice;
  29.         } else if (fishersCount > 11) {
  30.             discount = 0.25 * boatPrice;
  31.         }
  32.  
  33.         if(fishersCount % 2 == 0 && !season.equals("Autumn")){
  34.             discount += 0.05 * boatPrice;
  35.         }
  36.  
  37.         boatPrice -= discount;
  38.  
  39.         if(budget >= boatPrice){
  40.             double moneyLeft = budget - boatPrice;
  41.             System.out.printf("Yes! You have %.2f leva left.", moneyLeft);
  42.         } else {
  43.             double moneyLack = boatPrice - budget;
  44.             System.out.printf("Not enough money! You need %.2f leva.", moneyLack);
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement