Advertisement
elvirynwa

HotelRoom

Mar 27th, 2019
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.08 KB | None | 0 0
  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) {
  28.  
  29.                     finalPriceA = pricesMayOctoberA * nights;
  30.                     finalPriceS = priceMayOctoberS * nights;
  31.  
  32.                 }else if (nights < 14) {
  33.                     finalPriceA = pricesMayOctoberA * nights;
  34.                     discountForStudio = priceMayOctoberS - (priceMayOctoberS * 0.05);
  35.                     finalPriceS = discountForStudio * nights;
  36.  
  37.                 } else {
  38.  
  39.                     discountForApartments = pricesMayOctoberA - (pricesMayOctoberA * 0.10);
  40.                     finalPriceA = discountForApartments * nights;
  41.                     discountForStudio = priceMayOctoberS - (priceMayOctoberS * 0.30);
  42.                     finalPriceS = discountForStudio * nights;
  43.  
  44.                 }
  45.                 System.out.printf("Apartment: %.2f lv.\n", finalPriceA);
  46.                 System.out.printf("Studio: %.2f lv.", finalPriceS);
  47.                 break;
  48.  
  49.             case "june":
  50.             case "september":
  51.                 if (nights > 14) {
  52.                     discountForApartments = pricesJuneSeptemberA - (pricesJuneSeptemberA * 0.10);
  53.                     finalPriceA = discountForApartments * nights;
  54.                     discountForStudio = pricesJuneSeptemberS - (pricesJuneSeptemberS * 0.20);
  55.                     finalPriceS = discountForStudio * nights;
  56.  
  57.                 } else {
  58.                     finalPriceA = pricesJuneSeptemberA * nights;
  59.                     finalPriceS = pricesJuneSeptemberS * nights;
  60.  
  61.                 }
  62.                 System.out.printf("Apartment: %.2f lv.\n", finalPriceA);
  63.                 System.out.printf("Studio: %.2f lv.", finalPriceS);
  64.                 break;
  65.  
  66.             case "july":
  67.             case "august":
  68.                 if (nights > 14) {
  69.                     discountForApartments = pricesJulyAugustA - (pricesJulyAugustA * 0.10);
  70.                     finalPriceA = discountForApartments * nights;
  71.                     finalPriceS = pricesJulyAugustS * nights;
  72.                 } else {
  73.                     finalPriceA = pricesJulyAugustA * nights;
  74.                     finalPriceS = pricesJulyAugustS * nights;
  75.                 }
  76.                 System.out.printf("Apartment: %.2f lv.\n", finalPriceA);
  77.                 System.out.printf("Studio: %.2f lv.", finalPriceS);
  78.                 break;
  79.         }
  80.     }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement