Advertisement
myrdok123

P07HotelRoom

Jan 22nd, 2023
1,039
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.71 KB | None | 0 0
  1. package L03ConditionalStatementsAdvanced.Exercises;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P07HotelRoom {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         String month = scanner.nextLine();
  10.         int countNights = Integer.parseInt(scanner.nextLine());
  11.  
  12.         //May, June, July, August, September или October
  13.         double apartmentPrice = 0;
  14.         double studioPrice = 0;
  15.  
  16.         switch (month){
  17.             case "May":
  18.             case "October":
  19.                 apartmentPrice = countNights * 65;
  20.                 studioPrice = countNights * 50;
  21.                 if (countNights > 14){
  22.                     apartmentPrice = apartmentPrice * 0.9;
  23.                     studioPrice = studioPrice * 0.7;
  24.                 }else if(countNights > 7) {
  25.                     studioPrice = studioPrice * 0.95;
  26.  
  27.                 }
  28.  
  29.                 break;
  30.             case "June":
  31.             case "September":
  32.                 apartmentPrice = countNights * 68.70;
  33.                 studioPrice = countNights * 75.20;
  34.                 if(countNights > 14){
  35.                     apartmentPrice = apartmentPrice * 0.9;
  36.                     studioPrice = studioPrice * 0.8;
  37.                 }
  38.  
  39.                 break;
  40.  
  41.             case "July":
  42.             case "August":
  43.                 apartmentPrice = countNights * 77;
  44.                 studioPrice = countNights * 76;
  45.                 if(countNights > 14){
  46.                     apartmentPrice = apartmentPrice * 0.9;
  47.  
  48.                 }
  49.                 break;
  50.         }
  51.  
  52.         System.out.printf("Apartment: %.2f lv.%n", apartmentPrice);
  53.         System.out.printf("Studio: %.2f lv.", studioPrice);
  54.     }
  55. }
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement