Advertisement
CR7CR7

HotelRoom

Mar 13th, 2023
732
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.43 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class HotelRoom {
  4.  
  5.     public static void main(String[] args) {
  6.  
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         String month = scanner.nextLine();
  10.         int nights = Integer.parseInt(scanner.nextLine());
  11.  
  12.         double apartment = 0;
  13.         double studio = 0;
  14.  
  15.         switch (month){
  16.             case "May":
  17.             case "October":
  18.                 apartment = 65.00;
  19.                 studio = 50.00;
  20.                 break;
  21.             case "June":
  22.             case "September":
  23.                 apartment = 68.70;
  24.                 studio = 75.20;
  25.                 break;
  26.             case "July":
  27.             case "August":
  28.                 apartment = 77.00;
  29.                 studio = 76.00;
  30.                 break;
  31.         }
  32.  
  33.         if ((month.equals("May") || month.equals("October")) && nights > 14){
  34.             studio = studio - (studio * 0.30);
  35.         } else if ((month.equals("May") || month.equals("October")) && nights > 7){
  36.             studio = studio - (studio * 0.05);
  37.         } else if ((month.equals("June") || month.equals("September")) && nights > 14){
  38.             studio = studio - (studio * 0.20);
  39.         }
  40.  
  41.         if (nights > 14){
  42.             apartment = apartment - (apartment * 0.10);
  43.         }
  44.  
  45.         System.out.printf("Apartment: %.2f lv.%n",nights * apartment);
  46.         System.out.printf("Studio: %.2f lv.",nights * studio);
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement