Guest User

02. Reservation

a guest
Mar 23rd, 2020
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.45 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Reservation
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int reservationDay = int.Parse(Console.ReadLine());
  10.             int reservationMonth = int.Parse(Console.ReadLine());
  11.             int accommodationDay = int.Parse(Console.ReadLine());
  12.             int accommodationMonth = int.Parse(Console.ReadLine());
  13.             int leavingDay = int.Parse(Console.ReadLine());
  14.             int leavingMonth = int.Parse(Console.ReadLine());
  15.             double price = 0;
  16.  
  17.             double priceForRoom = 0;
  18.             double days = leavingDay - accommodationDay;
  19.            
  20.             if (accommodationMonth == reservationMonth)
  21.             {
  22.                 if (accommodationDay - reservationDay < 10)
  23.                 {
  24.                     priceForRoom = 30;
  25.                     price = days * priceForRoom;
  26.                 }
  27.                 else
  28.                 {
  29.                     priceForRoom = 25;
  30.                     price = days * priceForRoom;
  31.                 }
  32.             }
  33.             else if (accommodationMonth - reservationMonth == 1)
  34.             {
  35.                 priceForRoom = 25;
  36.                 price = (days * priceForRoom) - (days * priceForRoom * 0.20);
  37.             }
  38.  
  39.            
  40.  
  41.             Console.WriteLine($"Your stay from {accommodationDay}/{accommodationMonth} to {leavingDay}/{leavingMonth} will cost {price:F2}");
  42.            
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment