BapBapuHa

Hotel Room

Jan 27th, 2020
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.31 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.  
  9.         Scanner scanner = new Scanner(System.in);
  10.         String month = scanner.nextLine();
  11.         int numberOfNights = Integer.parseInt(scanner.nextLine());
  12.         double apartmentPrice = 0.0;
  13.         double studioPrice = 0.0;
  14.         if (month.equals("May") || month.equals("October")) {
  15.             apartmentPrice = 65;
  16.             studioPrice = 50;
  17.             if (numberOfNights > 14) {
  18.                 studioPrice = studioPrice * 0.70;
  19.             } else if (numberOfNights > 7) {
  20.                 studioPrice = studioPrice * 0.95;
  21.             }
  22.         } else if (month.equals("June") || month.equals("September")) {
  23.             if (numberOfNights > 14) {
  24.              apartmentPrice = 68.70;
  25.              studioPrice = 75.20;
  26.                 studioPrice = studioPrice * 0.8;
  27.         }
  28.         } else if (month.equals("July") || month.equals("August")) {
  29.              apartmentPrice = 77;
  30.              studioPrice = 76;
  31.         }
  32.             if (numberOfNights > 14) {
  33.                 apartmentPrice = apartmentPrice * 0.9;
  34.             }
  35.         System.out.printf("Apartment: %.2f lv.%nStudio: %.2f lv.", (numberOfNights * apartmentPrice), (numberOfNights * studioPrice));
  36.     }
  37.  
  38. }
Add Comment
Please, Sign In to add comment