BapBapuHa

FishingBoat

Jan 27th, 2020
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.06 KB | None | 0 0
  1. package com.company;
  2.  
  3.         import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.  
  9.         Scanner scanner = new Scanner(System.in);
  10.         int budget = Integer.parseInt(scanner.nextLine());
  11.         String season = scanner.nextLine();
  12.         int fishermans = Integer.parseInt(scanner.nextLine());
  13.         double cost = 0.0;
  14.         if (season.equals("Spring")) {
  15.             cost = 3000.0;
  16.             if (fishermans <= 6) {
  17.                 cost = cost * 0.9;
  18.             } else if (fishermans <= 11) {
  19.                 cost = cost * 0.85;
  20.             } else {
  21.                 cost = cost * 0.75;
  22.             }
  23.             if (fishermans % 2 == 0) {
  24.                 cost = cost * 0.95;
  25.             }
  26.         } else if (season.equals("Summer")) {
  27.             cost = 4200.0;
  28.             if (fishermans <= 6) {
  29.                 cost = cost * 0.9;
  30.             } else if (fishermans <= 11) {
  31.                 cost = cost * 0.85;
  32.             } else {
  33.                 cost = cost * 0.75;
  34.             }
  35.             if (fishermans % 2 == 0) {
  36.                 cost = cost * 0.95;
  37.             }
  38.         } else if (season.equals("Autumn")) {
  39.             cost = 4200.0;
  40.             if (fishermans <= 6) {
  41.                 cost = cost * 0.9;
  42.             } else if (fishermans <= 11) {
  43.                 cost = cost * 0.85;
  44.             } else {
  45.                 cost = cost * 0.75;
  46.             }
  47.         } else if (season.equals("Winter")) {
  48.             cost = 2600.0;
  49.             if (fishermans <= 6) {
  50.                 cost = cost * 0.9;
  51.             } else if (fishermans <= 11) {
  52.                 cost = cost * 0.85;
  53.             } else {
  54.                 cost = cost * 0.75;
  55.             }
  56.             if (fishermans % 2 == 0) {
  57.                 cost = cost * 0.95;
  58.             }
  59.         }
  60.         if (budget >= cost) {
  61.             System.out.printf("Yes! You have %.2f leva left.", (budget - cost));
  62.         } else {
  63.             System.out.printf("Not enough money! You need %.2f leva.", (cost - budget));
  64.         }
  65.     }
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment