Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class HotelRoom {
- public static void main(String[] args) {
- Scanner console = new Scanner(System.in);
- String month = console.nextLine();
- int overNights = Integer.parseInt(console.nextLine());
- double studioDiscount = 0 ;
- double apartmentDiscount = 0;
- double studioPrice = 0;
- double apartmentPrice = 0;
- double studioTotalPrice = 0;
- double apartmentTotalPrice = 0;
- if(month.equals("May") || month.equals("October")){
- studioPrice = overNights * 50.00;
- apartmentPrice = overNights * 65.00;
- if(overNights > 7 && overNights <= 14){
- studioDiscount = studioPrice * 0.05;
- studioPrice = studioPrice - studioDiscount;
- }else if(overNights > 14){
- studioDiscount = studioPrice * 0.30;
- apartmentDiscount = apartmentPrice * 0.10;
- studioPrice = studioPrice - studioDiscount;
- apartmentPrice = apartmentPrice - apartmentDiscount;
- }
- }else if(month.equals("June") || month.equals("September")){
- studioPrice = overNights * 75.20;
- apartmentPrice = overNights * 68.70;
- if(overNights > 14 ){
- studioDiscount = studioPrice * 0.20;
- apartmentDiscount = apartmentPrice * 0.10;
- studioPrice = studioPrice - studioDiscount;
- apartmentPrice = apartmentPrice - apartmentDiscount;
- }
- }else if(month.equals("July") || month.equals("August")){
- studioPrice = overNights * 76.00;
- apartmentPrice = overNights * 77.00;
- if(overNights > 14 ){
- apartmentDiscount = apartmentPrice * 0.10;
- apartmentPrice = apartmentPrice - apartmentDiscount;
- }
- }
- System.out.printf("Apartment: %.2f lv.\n",apartmentPrice);
- System.out.printf("Studio: %.2f lv.\n",studioPrice);
- }
- }
Add Comment
Please, Sign In to add comment