Advertisement
Silviyaa

O4 Fishing Boat

Feb 22nd, 2021
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.42 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class O4FishingBoat {
  4.     public static void main(String[] args) {
  5.  
  6.         Scanner scanner = new Scanner(System.in);
  7.  
  8.         int budgetGroup = Integer.parseInt(scanner.nextLine()); //Бюджет на групата
  9.         String season = scanner.nextLine(); //"Spring" , "Summer", "Autumn", "Winter"
  10.         int numberFished = Integer.parseInt(scanner.nextLine()); //Брой рибари
  11.  
  12.  
  13.         double price = 0;
  14.  
  15.         switch (season) {
  16.             case "Spring":
  17.                 price += 3000;
  18.                 break;
  19.             case "Summer":
  20.             case "Autumn":
  21.                 price += 4200;
  22.                 break;
  23.             case "Winter":
  24.                 price += 2600;
  25.                 break;
  26.         }
  27.         if(numberFished <= 6)
  28.         {
  29.             price *= 0.90; //discount 10%
  30.         }else if(numberFished >7 && numberFished <=11)
  31.         {
  32.             price *= 0.85;
  33.         }else if(numberFished >=12)
  34.         {
  35.             price *=0.75;
  36.         }
  37.  
  38.         if (numberFished % 2 == 0 && season != "Autumn") {
  39.             price *= 0.95;
  40.         }
  41.  
  42.         if(budgetGroup >= price)
  43.         {
  44.             System.out.printf("Yes! You have %.2f leva left.",Math.abs(budgetGroup-price));
  45.         }else if(budgetGroup <= price){
  46.             System.out.printf("Not enough money! You need %.2f leva.",Math.abs(price-budgetGroup));
  47.         }
  48.     }
  49. }
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement