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 numberNights = Integer.parseInt(scanner.nextLine());
- double priseStudio = 0.0;
- double priseApartment = 0.0;
- double discountStudio = 0.0;
- double discountApartment = 0.0;
- double totalStudio = 0.0;
- double totalApartment = 0.0;
- if (month.equals("May") || month.equals("October")) {
- priseStudio = 50;
- priseApartment = 65;
- if (numberNights > 7 && numberNights <= 14) {
- discountStudio = 0.05;
- } else if (numberNights > 14) {
- discountStudio = 0.3;
- discountApartment = 0.1;
- }
- }
- if (month.equals("June") || month.equals("September")) {
- priseStudio = 75.20;
- priseApartment = 68.70;
- if (numberNights > 14) {
- discountStudio = 0.20;
- discountApartment = 0.1;
- } else {
- }
- }
- if (month.equals("July") || month.equals("August")) {
- priseStudio = 76;
- priseApartment = 77;
- if (numberNights > 14) {
- discountApartment = 0.1;
- } else {
- }
- }
- totalStudio = (priseStudio - priseStudio * discountStudio) * numberNights;
- totalApartment = (priseApartment - priseApartment * discountApartment) * numberNights;
- System.out.printf("Apartment: %.2f lv. %n", totalApartment);
- System.out.printf("Studio: %.2f lv.", totalStudio);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement