Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class HotelRoom {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String months = scanner.nextLine();
- int nights = Integer.parseInt(scanner.nextLine());
- double priceMayOctoberS = 50;
- double pricesMayOctoberA = 65;
- double pricesJuneSeptemberS = 75.20;
- double pricesJuneSeptemberA = 68.70;
- double pricesJulyAugustS = 76;
- double pricesJulyAugustA = 77;
- double discountForStudio = 0;
- double discountForApartments = 0;
- double finalPriceS = 0;
- double finalPriceA = 0;
- switch (months.toLowerCase()) {
- case "may":
- case "october":
- if (nights <= 7) {
- finalPriceA = pricesMayOctoberA * nights;
- finalPriceS = priceMayOctoberS * nights;
- }else if (nights < 14) {
- finalPriceA = pricesMayOctoberA * nights;
- discountForStudio = priceMayOctoberS - (priceMayOctoberS * 0.05);
- finalPriceS = discountForStudio * nights;
- } else {
- discountForApartments = pricesMayOctoberA - (pricesMayOctoberA * 0.10);
- finalPriceA = discountForApartments * nights;
- discountForStudio = priceMayOctoberS - (priceMayOctoberS * 0.30);
- finalPriceS = discountForStudio * nights;
- }
- System.out.printf("Apartment: %.2f lv.\n", finalPriceA);
- System.out.printf("Studio: %.2f lv.", finalPriceS);
- break;
- case "june":
- case "september":
- if (nights > 14) {
- discountForApartments = pricesJuneSeptemberA - (pricesJuneSeptemberA * 0.10);
- finalPriceA = discountForApartments * nights;
- discountForStudio = pricesJuneSeptemberS - (pricesJuneSeptemberS * 0.20);
- finalPriceS = discountForStudio * nights;
- } else {
- finalPriceA = pricesJuneSeptemberA * nights;
- finalPriceS = pricesJuneSeptemberS * nights;
- }
- System.out.printf("Apartment: %.2f lv.\n", finalPriceA);
- System.out.printf("Studio: %.2f lv.", finalPriceS);
- break;
- case "july":
- case "august":
- if (nights > 14) {
- discountForApartments = pricesJulyAugustA - (pricesJulyAugustA * 0.10);
- finalPriceA = discountForApartments * nights;
- finalPriceS = pricesJulyAugustS * nights;
- } else {
- finalPriceA = pricesJulyAugustA * nights;
- finalPriceS = pricesJulyAugustS * nights;
- }
- System.out.printf("Apartment: %.2f lv.\n", finalPriceA);
- System.out.printf("Studio: %.2f lv.", finalPriceS);
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement