Advertisement
Guest User

Untitled

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