Advertisement
A_Marinov

Untitled

May 4th, 2020
510
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.86 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class FishingBoat_05 {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.         int budget = Integer.parseInt(scan.nextLine());
  7.         String season = scan.nextLine();
  8.         int fishermans = Integer.parseInt(scan.nextLine());
  9.         double rent = 0.0;
  10.         switch (season) {
  11.             case "Spring":
  12.                 rent = 3000;
  13.                 break;
  14.             case "Summer":
  15.             case "Autumn":
  16.                 rent = 4200;
  17.                 break;
  18.             case "Winter":
  19.                 rent = 2600;
  20.                 break;
  21.         }
  22.         //•   Ако групата е до 6 човека включително  –  отстъпка от 10%.
  23.         //•   Ако групата е от 7 до 11 човека включително  –  отстъпка от 15%.
  24.         //•   Ако групата е от 12 нагоре  –  отстъпка от 25%.
  25.         //Рибарите ползват допълнително 5% отстъпка ако са четен брой освен ако не е есен - тогава нямат допълнителна отстъпка.
  26.         if (fishermans <= 6) {
  27.             rent = rent - 0.10 * rent;
  28.         } else if (fishermans <= 11) {
  29.             rent = rent - 0.15 * rent;
  30.         } else if (fishermans > 12) {
  31.             rent = rent - 0.25 * rent;
  32.         }
  33.         if (fishermans % 2 == 0 && !season.equals("Autumn")) {
  34.             rent = rent - 0.05;
  35.         }
  36.         if (budget >= rent) {
  37.             double moneyLeft = budget - rent;
  38.             System.out.printf("Yes! You have %.2f leva left.", moneyLeft);
  39.         } else if (budget < rent) {
  40.             double moneyNeed = rent - budget;
  41.             System.out.printf("Not enough money! You need %.2f leva.", moneyNeed);
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement