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 nights = Integer.parseInt(scanner.nextLine());
- double priceApartment = 0;
- double priceStudio = 0;
- if (month.equals("May") || month.equals("October")) {
- if (nights > 7 && nights <= 14) {
- priceApartment = 65 * nights;
- priceStudio = 50 * 0.95 * nights;
- } else if (nights > 14) {
- priceApartment = 65 * 0.9 * nights;
- priceStudio = 50 * 0.7 * nights;
- } else {
- priceApartment = 65 * nights;
- priceStudio = 50 * nights;
- }
- }
- if (month.equals("June") || month.equals("September")) {
- if (nights > 7 && nights <= 14) {
- priceApartment = 68.70 * nights;
- priceStudio = 75.20 * nights;
- } else if (nights > 14) {
- priceApartment = 68.70 * 0.9 * nights;
- priceStudio = 75.20 * 0.8 * nights;
- } else {
- priceApartment = 68.7 * nights;
- priceStudio = 75.20 * nights;
- }
- }
- if (month.equals("July") || month.equals("August")) {
- if (nights > 7 && nights <= 14) {
- priceApartment = 77 * nights;
- priceStudio = 76 * nights;
- } else if (nights > 14) {
- priceApartment = 77 * 0.9 * nights;
- priceStudio = 76 * nights;
- } else {
- priceApartment = 77 * nights;
- priceStudio = 76 * nights;
- }
- }
- System.out.printf("Apartment: %.2f lv.%n", priceApartment);
- System.out.printf("Studio: %.2f lv.", priceStudio);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement