SHARE
TWEET

Untitled

elvirynwa Nov 3rd, 2018 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class HotelRoom {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         String months = scanner.nextLine();
  8.         int nights = Integer.parseInt(scanner.nextLine());
  9.  
  10.         double priceMayOctoberS = 50;
  11.         double pricesMayOctoberA = 65;
  12.  
  13.         double pricesJuneSeptemberS = 75.20;
  14.         double pricesJuneSeptemberA = 68.70;
  15.  
  16.         double pricesJulyAugustS = 76;
  17.         double pricesJulyAugustA = 77;
  18.  
  19.         double discountForStudio = 0;
  20.         double discountForApartments = 0;
  21.         double finalPriceS = 0;
  22.         double finalPriceA = 0;
  23.  
  24.         switch (months.toLowerCase()) {
  25.             case "may":
  26.             case "october":
  27.                 if (nights > 7 && nights < 14) {
  28.                     finalPriceA = pricesMayOctoberA * nights;
  29.                     discountForStudio = priceMayOctoberS - (priceMayOctoberS * 0.05);
  30.                     finalPriceS = discountForStudio * nights;
  31.  
  32.                     System.out.printf("Apartment: %.2f lv.\n", finalPriceA);
  33.                     System.out.printf("Studio: %.2f lv.", finalPriceS);
  34.                 } else {
  35.                     discountForApartments = pricesMayOctoberA - (pricesMayOctoberA * 0.10);
  36.                     finalPriceA = discountForApartments * nights;
  37.                     discountForStudio = priceMayOctoberS - (priceMayOctoberS * 0.30);
  38.                     finalPriceS = discountForStudio * nights;
  39.                     System.out.printf("Apartment: %.2f lv.\n", finalPriceA);
  40.                     System.out.printf("Studio: %.2f lv.", finalPriceS);
  41.                 }
  42.                 break;
  43.  
  44.             case "june":
  45.             case "september":
  46.                 if (nights > 14) {
  47.                     discountForApartments = pricesJuneSeptemberA - (pricesJuneSeptemberA * 0.10);
  48.                     finalPriceA = discountForApartments * nights;
  49.                     discountForStudio = pricesJuneSeptemberS - (pricesJuneSeptemberS * 0.20);
  50.                     finalPriceS = discountForStudio * nights;
  51.                     System.out.printf("Apartment: %.2f lv.\n", finalPriceA);
  52.                     System.out.printf("Studio: %.2f lv.", finalPriceS);
  53.                 } else {
  54.                     finalPriceA = pricesJuneSeptemberA * nights;
  55.                     finalPriceS = pricesJuneSeptemberS * nights;
  56.                     System.out.printf("Apartment: %.2f lv.\n", finalPriceA);
  57.                     System.out.printf("Studio: %.2f lv.", finalPriceS);
  58.                 }
  59.                 break;
  60.  
  61.             case "july":
  62.             case "august":
  63.                 if (nights > 14) {
  64.                     discountForApartments = pricesJulyAugustA - (pricesJulyAugustA * 0.10);
  65.                     finalPriceA = discountForApartments * nights;
  66.                     finalPriceS = pricesJulyAugustS * nights;
  67.                     System.out.printf("Apartment: %.2f lv.\n", finalPriceA);
  68.                     System.out.printf("Studio: %.2f lv.", finalPriceS);
  69.                 } else {
  70.                     finalPriceA = pricesJulyAugustA * nights;
  71.                     finalPriceS = pricesJulyAugustS * nights;
  72.                     System.out.printf("Apartment: %.2f lv.\n", finalPriceA);
  73.                     System.out.printf("Studio: %.2f lv.", finalPriceS);
  74.                 }
  75.                 break;
  76.         }
  77.     }
  78. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top