SHARE
TWEET

Untitled

a guest Sep 11th, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Reservation {
  6.     public static void main(String[] args) {
  7.         Scanner input = new Scanner(System.in);
  8.  
  9.         int dayFirstReservation = Integer.parseInt(input.nextLine());
  10.         int monthFirstReservation = Integer.parseInt(input.nextLine());
  11.         int dayForComing = Integer.parseInt(input.nextLine());
  12.         int monthForComing = Integer.parseInt(input.nextLine());
  13.         int dayForLeaving = Integer.parseInt(input.nextLine());
  14.         int monthForLeaving = Integer.parseInt(input.nextLine());
  15.         double sum;
  16.         if (monthForComing == monthForLeaving) {
  17.             if (dayForComing - dayFirstReservation == 10) {
  18.                 sum = (dayForLeaving - dayForComing) * 25;
  19.                 System.out.printf("Your stay from %d/%d to %d/%d will cost %.2f", dayForComing, monthForComing, dayForLeaving, monthForLeaving, sum);
  20.             } else if (monthForComing - monthFirstReservation == 1) {
  21.                 sum = (dayForLeaving - dayForComing) * 25;
  22.                 double discountSum = 0.20 * sum;
  23.                 double finalSum = sum - discountSum;
  24.                 System.out.printf("Your stay from %d/%d to %d/%d will cost %.2f", dayForComing, monthForComing, dayForLeaving, monthForLeaving, finalSum);
  25.             } else {
  26.  
  27.                 sum = (dayForLeaving - dayForComing) * 30;
  28.                 System.out.printf("Your stay from %d/%d to %d/%d will cost %.2f", dayForComing, monthForComing, dayForLeaving, monthForLeaving, sum);
  29.             }
  30.         } else {
  31.             System.out.println("Error");
  32.         }
  33.  
  34.     }
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top