Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class O7HotelRoom {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- String month = scan.nextLine();
- int nights = Integer.parseInt(scan.nextLine());
- double apartmentPrice = 0;
- double studioPrice = 0;
- switch (month) {
- case "May":
- case "October":
- apartmentPrice = 65;
- studioPrice = 50;
- break;
- case "June":
- case "September":
- apartmentPrice = 68.70;
- studioPrice = 75.20;
- break;
- case "July":
- case "August":
- apartmentPrice = 77;
- studioPrice = 76;
- break;
- }
- if (nights > 14) {
- apartmentPrice = apartmentPrice * 0.90;
- if (month.equals("May") || month.equals("October")) {
- studioPrice = studioPrice * 0.70;
- } else if (month.equals("June") || month.equals("September")) {
- studioPrice = studioPrice * 0.80;
- }
- } else if (nights > 7 && (month.equals("May") || month.equals("October"))) {
- studioPrice = studioPrice * 0.95;
- }
- double sumApartment = apartmentPrice * nights;
- double sumStudio = studioPrice * nights;
- System.out.printf("Apartment: %.2f lv.%n", sumApartment);
- System.out.printf("Studio: %.2f lv.%n", sumStudio);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement