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 mount = scanner.nextLine();
- int nights = Integer.parseInt(scanner.nextLine());
- double apartmentPricePerNight = 0;
- double studioPricePerNight = 0;
- switch (mount) {
- case "May", "October" -> {
- apartmentPricePerNight = 65;
- studioPricePerNight = 50;
- if (nights > 7 && nights <= 14) {
- studioPricePerNight *= 0.95;
- } else if (nights > 14) {
- studioPricePerNight *= 0.7;
- }
- }
- case "June", "September" -> {
- apartmentPricePerNight = 68.7;
- studioPricePerNight = 75.2;
- if (nights > 14) {
- studioPricePerNight *= 0.8;
- }
- }
- case "July", "August" -> {
- apartmentPricePerNight = 77;
- studioPricePerNight = 76;
- }
- }
- if (nights > 14) {
- apartmentPricePerNight *= 0.9;
- }
- System.out.printf("Apartment: %.2f lv./nStudio: %.2f lv.", apartmentPricePerNight * nights, studioPricePerNight * nights);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement