Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.61 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Reservation {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int dayOfReservation = Integer.parseInt(scanner.nextLine());
  8.         int mountOfReservation = Integer.parseInt(scanner.nextLine());
  9.         int dayOfArrive = Integer.parseInt(scanner.nextLine());
  10.         int mountArrive = Integer.parseInt(scanner.nextLine());
  11.         int dayLeaving = Integer.parseInt(scanner.nextLine());
  12.         int mountLeaving = Integer.parseInt(scanner.nextLine());
  13.  
  14.         int differenceDay = dayOfArrive-dayOfReservation;
  15.         int differenceMount = mountArrive-mountOfReservation;
  16.  
  17.         if(differenceMount>=1){
  18.             int price = 25;
  19.             double totalPrice = (dayLeaving-dayOfArrive)*price*0.80;
  20.             System.out.printf("Your stay from %d/%d to %d/%d ",dayOfArrive,mountArrive,dayLeaving,mountLeaving);
  21.             System.out.printf("will cost %.2f",totalPrice);
  22.  
  23.  
  24.         }else if(differenceDay>=10 && differenceMount == 0){
  25.             int price = 25;
  26.             int totalPrice = (dayLeaving-dayOfArrive)*price;
  27.             System.out.printf("Your stay from %d/%d to %d/%d ",dayOfArrive,mountArrive,dayLeaving,mountLeaving);
  28.             System.out.printf("will cost %.2d",totalPrice);
  29.         }else if(differenceDay<10 && differenceMount == 0){
  30.             int totalPrice = (dayLeaving-dayOfArrive)*30;
  31.             System.out.printf("Your stay from %d/%d to %d/%d ",dayOfArrive,mountArrive,dayLeaving,mountLeaving);
  32.             System.out.printf("will cost %.2d",totalPrice);
  33.         }
  34.  
  35.  
  36.  
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement