Advertisement
CR7CR7

hotelRoom

Apr 28th, 2023
1,120
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.38 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ex7 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         String month = scanner.nextLine();
  7.         int countNights = Integer.parseInt(scanner.nextLine());
  8.         double priceApartment = 0;
  9.         double priceStudio = 0;
  10.  
  11.         if (month.equals("May") || month.equals("October")){ // change "Octomber" to "October"
  12.             priceApartment = 65.00;
  13.             priceStudio = 50.00;
  14.             if (countNights > 14){
  15.                 priceStudio *= 0.70;
  16.             }else if (countNights > 7){
  17.                 priceStudio *= 0.95;
  18.             }
  19.         }else if (month.equals("June") || month.equals("September")){
  20.             priceApartment = 68.70;
  21.             priceStudio = 75.20;
  22.             if (countNights > 14){
  23.                 priceStudio *= 0.80;
  24.             }
  25.         }else if (month.equals("July") || month.equals("August")){
  26.             priceApartment = 77.00;
  27.             priceStudio = 76.00;
  28.         }
  29.  
  30.  
  31.         if (countNights > 14){
  32.             priceApartment *= 0.90;
  33.         }
  34.  
  35.         double totalPriceApartment =priceApartment * countNights;
  36.         double totalPriceStudio =priceStudio * countNights;
  37.  
  38.  
  39.         System.out.printf("Apartment: %.2f lv.\n",totalPriceApartment);
  40.         System.out.printf("Studio: %.2f lv.",totalPriceStudio);
  41.     }
  42.  
  43.  
  44. }
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement