Advertisement
Guest User

Untitled

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