Advertisement
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 scanner = new Scanner(System.in);
- String month = scanner.nextLine();
- int daysCount = Integer.parseInt(scanner.nextLine());
- double studioPrice = 0;
- double apartmentPrice = 0;
- switch (month) {
- case "May":
- case "October":
- studioPrice = 50;
- apartmentPrice = 65;
- if (daysCount > 14) {
- studioPrice *= 0.7; // 30% discount
- apartmentPrice *= 0.9; // 10% discount
- } else if (daysCount > 7) {
- studioPrice *= 0.95; // 5% discount
- }
- break;
- case "June":
- case "September":
- studioPrice = 75.20;
- apartmentPrice = 68.70;
- if (daysCount > 14) {
- studioPrice *= 0.8; // 20% discount
- apartmentPrice *= 0.9; // 10% discount
- }
- break;
- case "July":
- case "August":
- studioPrice = 76;
- apartmentPrice = 77;
- if (daysCount > 14) {
- apartmentPrice *= 0.9; // 10% discount
- }
- break;
- }
- // Calculate the final prices for studio and apartment
- studioPrice *= daysCount;
- apartmentPrice *= daysCount;
- // Print the output formatted to two decimal places
- System.out.printf("Apartment: %.2f lv.%n", apartmentPrice);
- System.out.printf("Studio: %.2f lv.%n", studioPrice);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement