Guest User

Untitled

a guest
Oct 8th, 2018
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.56 KB | None | 0 0
  1. package fishingboat;
  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.  
  9.         double groupBudget = Double.parseDouble(scanner.nextLine());
  10.         String season = scanner.nextLine();
  11.         int fisher = Integer.parseInt(scanner.nextLine());
  12.  
  13.         double priceRent = 0;
  14.         if (season.equals("Spring")){
  15.             priceRent = 3000;
  16.         }else if (season.equals("Summer") || (season.equals("Autumn"))){
  17.             priceRent = 4200;
  18.         }else if (season.equals("Winter")){
  19.             priceRent = 2600;
  20.         }
  21.  
  22.         double discount = 0;
  23.         if (fisher <= 6){
  24.             discount = 0.10;
  25.         }else if (fisher >= 7 && fisher <= 11){
  26.             discount = 0.15;
  27.         }else if (fisher > 12){
  28.             discount = 0.25;
  29.         }
  30.        
  31.         if (fisher <= 6){
  32.             priceRent -= (priceRent * discount);
  33.         }else if (fisher >= 7 && fisher <= 11){
  34.             priceRent -= (priceRent * discount);
  35.         }else if (fisher > 12){
  36.             priceRent -=  (priceRent * discount);
  37.         }
  38.  
  39.         if ((fisher % 2 == 0) && (!season.equals("Autumn"))){
  40.             priceRent -=  (priceRent * 0.05);
  41.         }
  42.          
  43.         double result = Math.abs(priceRent - groupBudget);
  44.         if (priceRent > groupBudget){
  45.             System.out.printf("Not enough money! You need %.2f leva.",result);
  46.         }else{
  47.             System.out.printf("Yes! You have %.2f leva left.",result);
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment