Guest User

02. Reservation

a guest
Mar 22nd, 2020
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.34 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.  
  16.             double priceForRoom = 0;
  17.             double days = leavingDay - accommodationDay;
  18.             double price = days * priceForRoom; ;
  19.  
  20.             if (accommodationDay - reservationDay >= 10)
  21.             {
  22.                 priceForRoom = 25;
  23.                 price = days * priceForRoom;
  24.             }
  25.             else if (accommodationMonth - reservationMonth == 1)
  26.             {
  27.                 priceForRoom = 25;
  28.                 price -= (price * 0.20);
  29.                    
  30.             }
  31.             else
  32.             {
  33.                 priceForRoom = 30;
  34.                 price = days * priceForRoom;
  35.                
  36.             }
  37.  
  38.            
  39.  
  40.             Console.WriteLine($"Your stay from {accommodationDay}/{accommodationMonth} to {leavingDay}/{leavingMonth} will cost {price:F2}");
  41.            
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment