Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class E05HotelRoom {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String month = scanner.nextLine();
- int nights = Integer.parseInt(scanner.nextLine());
- double priceApartment = 0.00;
- double priceStudio = 0.00;
- double totalApartment = 00.00;
- double totalStudio = 00.00;
- switch (month) {
- case "May":
- case "October":
- priceApartment = 65;
- priceStudio = 50;
- if (nights > 7 && nights <= 14) {
- totalApartment = priceApartment * nights;
- totalStudio = priceStudio * nights - priceStudio * nights * 0.05;
- } else if (nights > 14) {
- totalApartment = priceApartment * nights - priceApartment * nights * 0.10;
- totalStudio = priceStudio * nights - priceStudio * nights * 0.30;
- } else {
- totalApartment = priceApartment * nights;
- totalStudio = priceStudio * nights;
- }
- break;
- case "June":
- case "September":
- priceApartment = 68.70;
- priceStudio = 75.20;
- if (nights > 14) {
- totalApartment = priceApartment * nights - priceApartment * nights * 0.10;
- totalStudio = priceStudio * nights - priceStudio * nights * 0.20;
- } else {
- totalApartment = priceApartment * nights;
- totalStudio = priceStudio * nights;
- }
- break;
- case "July":
- case "August":
- priceApartment = 77;
- priceStudio = 76;
- if (nights > 14) {
- totalApartment = priceApartment * nights - priceApartment * nights * 0.10;
- totalStudio = priceStudio * nights;
- } else {
- totalApartment = priceApartment * nights;
- totalStudio = priceStudio * nights;
- }
- break;
- default:
- System.out.println("unknown");
- break;
- }
- System.out.printf("Apartment: %.2f lv.%n", totalApartment);
- System.out.printf("Studio: %.2f lv.", totalStudio);
- }
- }
Add Comment
Please, Sign In to add comment