Advertisement
finderabc

HotelRoom

Feb 3rd, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.08 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class HotelRoom {
  3.  
  4.     public static void main(String[] args) {
  5.         Scanner in = new Scanner(System.in);
  6.         String month = in.nextLine();
  7.         int night = in.nextInt();
  8.         double price = 0;
  9.         double apartment = 0;
  10.         double studio = 0;
  11.        
  12.         switch(month) {
  13.         case "May":
  14.         case "October":
  15.             if(night <= 7) {
  16.                 apartment = night * 65;
  17.                 studio = night * 50;
  18.             }else if(night > 7 && night <= 14) {
  19.                 double discount = 50 * 0.05;
  20.                 studio = night * (50 - discount);
  21.                 apartment = night * 65;
  22.             }else if(night > 14) {
  23.                 double discount = 50 * 0.3;
  24.                 studio = night * (50 - discount);
  25.                
  26.                 double discountA = 65 * 0.1;
  27.                 apartment = night * (65 - discountA);
  28.             }
  29.             break;
  30.            
  31.         case "June":
  32.         case "September":
  33.             if(night <= 7) {
  34.                 apartment = night * 68.70;
  35.                 studio = night * 75.20;
  36.             }else if(night > 7 && night <= 14) {
  37.                 studio = night * 75.20;
  38.                 apartment = night * 68.70;
  39.             }else if(night > 14) {
  40.                 double discount = 75.20 * 0.2;
  41.                 studio = night * (75.20 - discount);
  42.                
  43.                 double discountA = 68.70 * 0.1;
  44.                 apartment = night * (68.70 - discountA);
  45.             }
  46.             break;
  47.            
  48.         case "July":
  49.         case "August":
  50.             if(night <=14) {
  51.                 studio = night * 76;
  52.                 apartment = night * 77;
  53.         }else if(night > 14) {
  54.                 studio = night * 76;
  55.                
  56.                 double discountA = 77 * 0.1;
  57.                 apartment = night * (77 - discountA);
  58.             }
  59.             break;
  60.            
  61.             default:
  62.                 System.out.println("error");
  63.         }
  64.         System.out.printf("Apartment: %.2f lv.", apartment);
  65.         System.out.printf("\nStudio: %.2f lv.", studio);
  66.     }
  67.  
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement