Advertisement
Deiancom

Fishing Boat

Jun 26th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.83 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class FishingBoat {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         int budget = Integer.parseInt(scanner.nextLine());
  9.         String season = scanner.nextLine();
  10.         int fishermanCount = Integer.parseInt(scanner.nextLine());
  11.         double priceForFishing = 0;
  12.         if (season.equals("Spring")) {
  13.             if (fishermanCount <= 6) {
  14.                 priceForFishing = 3000 - (3000 * 0.10);
  15.             } else if (fishermanCount <= 11) {
  16.                 priceForFishing = 3000 - (3000 * 0.15);
  17.             } else {
  18.                 priceForFishing = 3000 - (3000 * 0.25);
  19.             }
  20.         }
  21.         if (season.equals("Summer") || season.equals("Autumn")) {
  22.             if (fishermanCount <= 6) {
  23.                 priceForFishing = 4200 - (4200 * 0.10);
  24.             } else if (fishermanCount <= 11) {
  25.                 priceForFishing = 4200 - (4200 * 0.15);
  26.             } else {
  27.                 priceForFishing = 4200 - (4200 * 0.25);
  28.             }
  29.         }
  30.         if (season.equals("Winter")) {
  31.             if (fishermanCount <= 6) {
  32.                 priceForFishing = 2600 - (2600 * 0.10);
  33.             } else if (fishermanCount <= 11) {
  34.                 priceForFishing = 2600 - (2600 * 0.15);
  35.             } else {
  36.                 priceForFishing = 2600 - (2600 * 0.25);
  37.             }
  38.         }
  39.  
  40.         if (fishermanCount % 2 == 0 && (!season.equals("Autumn"))) {
  41.             priceForFishing *= 0.95;
  42.         }
  43.         if (budget >= priceForFishing) {
  44.             System.out.printf("Yes! You have %.2f leva left.", budget - priceForFishing);
  45.         }else if (priceForFishing < budget) {
  46.             System.out.printf("Not enough money! You need %,2f leva.",priceForFishing - budget);
  47.         }
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement