Silviyaa

Hotel room

Feb 22nd, 2021
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.91 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(); //May, June, July, August, September или October
  8.         int numberNight = Integer.parseInt(scanner.nextLine());
  9.  
  10.         double priceStudio = 0;
  11.         double priceApartments = 0;
  12.  
  13.         if (month.equals("May") || month.equals("October"))
  14.         {
  15.             priceStudio = 50;
  16.             priceApartments = 65;
  17.             if (numberNight > 7 && numberNight <=14)
  18.             {
  19.                 priceStudio = priceStudio * 0.95; // 5% намаление
  20.                 priceApartments = priceApartments * 1; //10% намаление
  21.             }else if (numberNight > 14)
  22.             {
  23.                 priceStudio = priceStudio * 0.70; // 30% намаление
  24.                 priceApartments = priceApartments * 0.90; // 10% намаление
  25.             }
  26.  
  27.         } else if (month.equals("June") || month.equals("September"))
  28.         {
  29.             priceStudio = 75.20;
  30.             priceApartments = 68.70;
  31.             if (numberNight > 14)
  32.             {
  33.                 priceStudio = priceStudio * 0.80; // 20% намаление
  34.                 priceApartments = priceApartments * 0.90; // 10% намаление
  35.             }
  36.         }else if (month.equals("July") || month.equals("August"))
  37.         {
  38.             priceStudio = 76;
  39.             priceApartments = 77;
  40.             if (numberNight >=14)
  41.             {
  42.                 priceApartments = priceApartments * 0.90; // 10% намаление
  43.             }
  44.         }
  45.         double totalSumApartments = numberNight * priceApartments;
  46.         double totalSumStudio = numberNight * priceStudio;
  47.         System.out.printf("Apartment: %.2f lv. %n" , totalSumApartments);
  48.         System.out.printf("Studio: %.2f lv.", totalSumStudio);
  49.     }
  50. }
  51.  
Advertisement
Add Comment
Please, Sign In to add comment