BubaLazi

p03_HotelRoom

Mar 16th, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.02 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class HotelRoom {
  4.     public static void main(String[] args) {
  5.         Scanner console = new Scanner(System.in);
  6.  
  7.         String month = console.nextLine();
  8.         int overNights = Integer.parseInt(console.nextLine());
  9.  
  10.         double studioDiscount = 0 ;
  11.         double apartmentDiscount = 0;
  12.         double studioPrice = 0;
  13.         double apartmentPrice = 0;
  14.         double studioTotalPrice = 0;
  15.         double apartmentTotalPrice = 0;
  16.  
  17.         if(month.equals("May") || month.equals("October")){
  18.             studioPrice = overNights * 50.00;
  19.             apartmentPrice = overNights * 65.00;
  20.             if(overNights > 7 && overNights <= 14){
  21.                 studioDiscount = studioPrice * 0.05;
  22.                 studioPrice = studioPrice - studioDiscount;
  23.             }else if(overNights > 14){
  24.                 studioDiscount = studioPrice * 0.30;
  25.                 apartmentDiscount = apartmentPrice * 0.10;
  26.                 studioPrice = studioPrice - studioDiscount;
  27.                 apartmentPrice = apartmentPrice - apartmentDiscount;
  28.             }
  29.         }else if(month.equals("June") || month.equals("September")){
  30.             studioPrice = overNights * 75.20;
  31.             apartmentPrice = overNights * 68.70;
  32.             if(overNights > 14 ){
  33.                 studioDiscount = studioPrice * 0.20;
  34.                 apartmentDiscount = apartmentPrice * 0.10;
  35.                 studioPrice = studioPrice - studioDiscount;
  36.                 apartmentPrice = apartmentPrice - apartmentDiscount;
  37.             }
  38.         }else if(month.equals("July") || month.equals("August")){
  39.             studioPrice = overNights * 76.00;
  40.             apartmentPrice = overNights * 77.00;
  41.             if(overNights > 14 ){
  42.                 apartmentDiscount = apartmentPrice * 0.10;
  43.                 apartmentPrice = apartmentPrice - apartmentDiscount;
  44.             }
  45.         }
  46.         System.out.printf("Apartment: %.2f lv.\n",apartmentPrice);
  47.         System.out.printf("Studio: %.2f lv.\n",studioPrice);
  48.  
  49.     }
  50. }
Add Comment
Please, Sign In to add comment