Advertisement
Spocoman

07. Hotel Room

Sep 18th, 2024
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.33 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.         String mount = scanner.nextLine();
  7.         int nights = Integer.parseInt(scanner.nextLine());
  8.  
  9.         double apartmentPricePerNight = 0;
  10.         double studioPricePerNight = 0;
  11.  
  12.         switch (mount) {
  13.             case "May", "October" -> {
  14.                 apartmentPricePerNight = 65;
  15.                 studioPricePerNight = 50;
  16.                 if (nights > 7 && nights <= 14) {
  17.                     studioPricePerNight *= 0.95;
  18.                 } else if (nights > 14) {
  19.                     studioPricePerNight *= 0.7;
  20.                 }
  21.             }
  22.             case "June", "September" -> {
  23.                 apartmentPricePerNight = 68.7;
  24.                 studioPricePerNight = 75.2;
  25.                 if (nights > 14) {
  26.                     studioPricePerNight *= 0.8;
  27.                 }
  28.             }
  29.             case "July", "August" -> {
  30.                 apartmentPricePerNight = 77;
  31.                 studioPricePerNight = 76;
  32.             }
  33.         }
  34.  
  35.         if (nights > 14) {
  36.             apartmentPricePerNight *= 0.9;
  37.         }
  38.  
  39.         System.out.printf("Apartment: %.2f lv./nStudio: %.2f lv.",  apartmentPricePerNight * nights, studioPricePerNight * nights);
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement