Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Reservation {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- int dayFirstReservation = Integer.parseInt(input.nextLine());
- int monthFirstReservation = Integer.parseInt(input.nextLine());
- int dayForComing = Integer.parseInt(input.nextLine());
- int monthForComing = Integer.parseInt(input.nextLine());
- int dayForLeaving = Integer.parseInt(input.nextLine());
- int monthForLeaving = Integer.parseInt(input.nextLine());
- double sum;
- if (monthForComing == monthForLeaving) {
- if (dayForComing - dayFirstReservation == 10) {
- sum = (dayForLeaving - dayForComing) * 25;
- System.out.printf("Your stay from %d/%d to %d/%d will cost %.2f", dayForComing, monthForComing, dayForLeaving, monthForLeaving, sum);
- } else if (monthForComing - monthFirstReservation == 1) {
- sum = (dayForLeaving - dayForComing) * 25;
- double discountSum = 0.20 * sum;
- double finalSum = sum - discountSum;
- System.out.printf("Your stay from %d/%d to %d/%d will cost %.2f", dayForComing, monthForComing, dayForLeaving, monthForLeaving, finalSum);
- } else {
- sum = (dayForLeaving - dayForComing) * 30;
- System.out.printf("Your stay from %d/%d to %d/%d will cost %.2f", dayForComing, monthForComing, dayForLeaving, monthForLeaving, sum);
- }
- } else {
- System.out.println("Error");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement