Helena12

FishingBoat

Oct 30th, 2018
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.34 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class EP06FishBoat {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int budget = Integer.parseInt(scanner.nextLine());
  8.         String season = scanner.nextLine();
  9.         int fishers = Integer.parseInt(scanner.nextLine());
  10.  
  11.         double price = 0;
  12.  
  13.         if (season.equalsIgnoreCase("spring")) {
  14.             price = 3000;
  15.             if (fishers % 2 == 0) {
  16.                 price *= 0.95;
  17.             }
  18.         }
  19.         else if (season.equalsIgnoreCase("summer") || season.equalsIgnoreCase("autumn")) {
  20.             price = 4200;
  21.             if (fishers % 2 == 0 && !season.equalsIgnoreCase("autumn")) {
  22.                 price *= 0.95;
  23.             }
  24.         }
  25.         else if (season.equalsIgnoreCase("winter")) {
  26.             price = 2600;
  27.             if (fishers % 2 == 0) {
  28.                 price *= 0.95;
  29.             }
  30.         }
  31.         if (fishers <= 6) {
  32.             price *= 0.90;
  33.         } else if (fishers <= 11) {
  34.             price *= 0.85;
  35.         } else  {
  36.             price *= 0.75;
  37.         }
  38.         if (budget >= price) {
  39.             System.out.printf("Yes! You have %.2f leva left.", budget - price);
  40. }
  41. else {
  42.             System.out.printf("Not enough money! You need %.2f leva.", price - budget);
  43.         }
  44.  
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment