deyanivanov966

07. Hotel Room

Aug 29th, 2020 (edited)
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.54 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class u3_HotelRoom {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         String month = scanner.nextLine();
  8.         double nights = Double.parseDouble(scanner.nextLine());
  9.  
  10.         double priceStudio = 50;
  11.         double priceApartment = 65;
  12.  
  13.  
  14.         if (month.equals("May") || month.equals("October")) {
  15.             priceStudio = 50;
  16.             priceApartment = 65;
  17.             if (nights > 7 && nights <= 14) {
  18.                 priceStudio = 50 - (50 * 0.05);
  19.  
  20.             } else if (nights > 14) {
  21.                 priceStudio = 50 - (50 * 0.3);
  22.                 priceApartment = 65 - (65 * 0.1);
  23.             }
  24.  
  25.         } else if (month.equals("June") || month.equals("September")) {
  26.             priceStudio = 75.2;
  27.             priceApartment = 68.70;
  28.             if (nights > 14) {
  29.                 priceStudio = 75.2 - (75.2 * 0.2);
  30.                 priceApartment = 68.70 - (68.70 * 0.1);
  31.             }
  32.  
  33.         } else if (month.equals("July") || month.equals("August")) {
  34.             priceStudio = 76;
  35.             priceApartment = 77;
  36.             if (nights > 14) {
  37.                 priceStudio = 76;
  38.                 priceApartment = 77 - (77 * 0.1);
  39.             }
  40.         }
  41.         double tottalPriceStudio = priceStudio*nights;
  42.         double tottalPriceApartment = priceApartment*nights;
  43.  
  44.         System.out.printf("Apartment: %.2f lv.%n", tottalPriceApartment);
  45.         System.out.printf("Studio: %.2f lv.%n", tottalPriceStudio);
  46.     }
  47. }
Add Comment
Please, Sign In to add comment