aggressiveviking

Untitled

Feb 24th, 2020
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.47 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _02.Reservation
  4. {
  5.     class Reservation
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int dayNow = int.Parse(Console.ReadLine());
  10.             int monthNow = int.Parse(Console.ReadLine());
  11.  
  12.             int checkInDay = int.Parse(Console.ReadLine());
  13.             int checkInMonth = int.Parse(Console.ReadLine());
  14.  
  15.             int checkOutDay = int.Parse(Console.ReadLine());
  16.             int checkOutMonth = int.Parse(Console.ReadLine());
  17.  
  18.             int nights = checkOutDay - checkInDay;
  19.             int daysApart = Math.Abs(dayNow - checkInDay);
  20.             int monthsApart = Math.Abs(monthNow - checkInMonth);
  21.  
  22.             bool earlyBooking10days = false;
  23.             bool earlyBooking1month = false;
  24.            
  25.             double price = 30;
  26.  
  27.             if (daysApart >= 10)
  28.             {
  29.                 earlyBooking10days = true;
  30.             }
  31.  
  32.             if (monthsApart >= 1)
  33.             {
  34.                 earlyBooking1month = true;
  35.                 earlyBooking10days = true;
  36.             }
  37.  
  38.             double cost = nights * price;
  39.            
  40.             if (earlyBooking10days)
  41.             {
  42.                 cost = nights * 25;
  43.             }
  44.  
  45.             if (earlyBooking1month)
  46.             {
  47.                 cost = cost * 0.8;
  48.             }
  49.  
  50.             Console.WriteLine($"Your stay from {checkInDay}/{checkInMonth} to {checkOutDay}/{checkOutMonth} will cost {cost:F2}");
  51.  
  52.         }
  53.     }
  54. }
Add Comment
Please, Sign In to add comment