Advertisement
GabrielHr00

07. Hotel Room

Mar 24th, 2024
675
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.68 KB | None | 0 0
  1. package _03_ConditionalStatementsAdvanced;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class HotelRoom {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         String month = scanner.nextLine();
  9.         int nights = Integer.parseInt(scanner.nextLine());
  10.  
  11.         double studioPrice = 0.0;
  12.         double apartmentPrice = 0.0;
  13.  
  14.         if (month.equals("May") || month.equals("October")) {
  15.             studioPrice = 50.0 * nights;
  16.             apartmentPrice = 65.0 * nights;
  17.  
  18.             if(nights > 7 && nights <= 14) {
  19.                 //studioPrice = studioPrice - (studioPrice * 0.05);
  20.                 studioPrice = studioPrice * 0.95;
  21.             } else if (nights > 14) {
  22.                 //studioPrice = studioPrice - (studioPrice * 0.30);
  23.                 studioPrice = studioPrice * 0.70;
  24.                 apartmentPrice = apartmentPrice * 0.90;
  25.             }
  26.         }
  27.         else if (month.equals("June") || month.equals("September")) {
  28.             studioPrice = 75.20 * nights;
  29.             apartmentPrice = 68.70 * nights;
  30.  
  31.             if (nights > 14) {
  32.                 //studioPrice = studioPrice - (studioPrice * 0.20);
  33.                 studioPrice = studioPrice * 0.80;
  34.                 apartmentPrice = apartmentPrice * 0.90;
  35.             }
  36.         }
  37.         else if (month.equals("July") || month.equals("August")) {
  38.             studioPrice = 76.0 * nights;
  39.             apartmentPrice = 77.0 * nights;
  40.  
  41.             if(nights > 14) {
  42.                 apartmentPrice = apartmentPrice * 0.90;
  43.             }
  44.         }
  45.  
  46.         System.out.printf("Apartment: %.2f lv.%nStudio: %.2f lv.", apartmentPrice, studioPrice);
  47.  
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement