mark79

Hotel Room

Apr 27th, 2019
225
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.  
  7.         String month = scanner.nextLine();
  8.         int overnights = Integer.parseInt(scanner.nextLine());
  9.  
  10.         double studioPrice = 0;
  11.         double apartmentPrice = 0;
  12.         switch (month) {
  13.             case "May":
  14.             case "October":
  15.                 studioPrice = 50;
  16.                 apartmentPrice = 65;
  17.                 if (overnights > 14) {
  18.                     studioPrice *= 0.7;
  19.                 } else if (overnights > 7) {
  20.                     studioPrice *= 0.95;
  21.                 }
  22.                 break;
  23.             case "June":
  24.             case "September":
  25.                 studioPrice = 75.2;
  26.                 apartmentPrice = 68.7;
  27.                 if (overnights > 14){
  28.                     studioPrice *= 0.8;
  29.                 }
  30.                 break;
  31.             case "July":
  32.             case "August":
  33.                 studioPrice = 76;
  34.                 apartmentPrice = 77;
  35.                 break;
  36.         }
  37.  
  38.         if (overnights > 14){
  39.             apartmentPrice *= 0.9;
  40.         }
  41.  
  42.         System.out.printf("Apartment: %.2f lv.%n", apartmentPrice * overnights);
  43.         System.out.printf("Studio: %.2f lv.", studioPrice * overnights);
  44.     }
  45. }
Add Comment
Please, Sign In to add comment