Advertisement
GabrielHr00

04. Fishing Boat

May 28th, 2023
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.55 KB | None | 0 0
  1. package S3_ConditionalStatementsAdvanced;
  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 fishersCount = Integer.parseInt(scanner.nextLine());
  11.  
  12.         double shipRent = 0.0;
  13.         if(season.equals("Spring")) {
  14.             shipRent = 3000.0;
  15.         }
  16.         else if (season.equals("Summer") || season.equals("Autumn")) {
  17.             shipRent = 4200.0;
  18.         }
  19.         else if (season.equals("Winter")) {
  20.             shipRent = 2600.0;
  21.         }
  22.  
  23.  
  24.         if(fishersCount <= 6) {
  25.             //shipRent = shipRent - (shipRent * 0.10);
  26.             shipRent = shipRent * 0.90;
  27.         } else if (fishersCount >= 7 && fishersCount <= 11) {
  28.             //shipRent = shipRent - (shipRent * 0.15);
  29.             shipRent = shipRent * 0.85;
  30.         } else if (fishersCount >= 12) {
  31.             //shipRent = shipRent - (shipRent * 0.25);
  32.             shipRent = shipRent * 0.75;
  33.         }
  34.  
  35.         if(fishersCount % 2 == 0 && !(season.equals("Autumn")) ) {
  36.             //shipRent = shipRent - (shipRent * 0.05);
  37.             shipRent = shipRent * 0.95;
  38.         }
  39.  
  40.  
  41.         double diff = Math.abs(budget - shipRent);
  42.         if (budget >= shipRent) {
  43.             System.out.printf("Yes! You have %.2f leva left.", diff);
  44.         } else {
  45.             System.out.printf("Not enough money! You need %.2f leva.", diff);
  46.         }
  47.     }
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement