Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String month = scanner.nextLine();
- int numberOfNights = Integer.parseInt(scanner.nextLine());
- double apartmentPrice = 0.0;
- double studioPrice = 0.0;
- if (month.equals("May") || month.equals("October")) {
- apartmentPrice = 65;
- studioPrice = 50;
- if (numberOfNights > 14) {
- studioPrice = studioPrice * 0.70;
- } else if (numberOfNights > 7) {
- studioPrice = studioPrice * 0.95;
- }
- } else if (month.equals("June") || month.equals("September")) {
- if (numberOfNights > 14) {
- apartmentPrice = 68.70;
- studioPrice = 75.20;
- studioPrice = studioPrice * 0.8;
- }
- } else if (month.equals("July") || month.equals("August")) {
- apartmentPrice = 77;
- studioPrice = 76;
- }
- if (numberOfNights > 14) {
- apartmentPrice = apartmentPrice * 0.9;
- }
- System.out.printf("Apartment: %.2f lv.%nStudio: %.2f lv.", (numberOfNights * apartmentPrice), (numberOfNights * studioPrice));
- }
- }
Add Comment
Please, Sign In to add comment