svephoto

Hotel Room [Java]

Apr 28th, 2021 (edited)
547
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class HotelRoom {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.  
  7.         String month = scan.nextLine();
  8.         int nights = Integer.parseInt(scan.nextLine());
  9.  
  10.         double studioPrice = 0.0;
  11.         double apartmentPrice = 0.0;
  12.  
  13.         if (month.equals("May") || month.equals("October")) {
  14.             studioPrice = nights * 50;
  15.             apartmentPrice = nights * 65;
  16.  
  17.             if (nights > 14) {
  18.                 studioPrice *= 0.7;
  19.                 apartmentPrice *= 0.9;
  20.             } else if (nights > 7) {
  21.                 studioPrice *= 0.95;
  22.             }
  23.         } else if (month.equals("June") || month.equals("September")) {
  24.             studioPrice = nights * 75.20;
  25.             apartmentPrice = nights * 68.70;
  26.  
  27.             if (nights > 14) {
  28.                 studioPrice *= 0.8;
  29.                 apartmentPrice *= 0.9;
  30.             }
  31.         } else if (month.equals("July") || month.equals("August")) {
  32.             studioPrice = nights * 76;
  33.             apartmentPrice = nights * 77;
  34.  
  35.             if (nights > 14) {
  36.                 apartmentPrice *= 0.9;
  37.             }
  38.         }
  39.  
  40.         System.out.printf("Apartment: %.2f lv.%n", apartmentPrice);
  41.         System.out.printf("Studio: %.2f lv.%n", studioPrice);
  42.     }
  43. }
  44.  
RAW Paste Data