Advertisement
Valantina

Reservation/EX 27.07.2019

Jul 29th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.44 KB | None | 0 0
  1. using System;
  2.  
  3. namespace P02_Reservation
  4. {
  5.     class P02_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.             double price = 30;
  25.  
  26.             if (daysApart >= 10)
  27.             {
  28.                 earlyBooking10days = true;
  29.             }
  30.  
  31.             if (monthsApart >= 1)
  32.             {
  33.                 earlyBooking1month = true;
  34.                 earlyBooking10days = true;
  35.             }
  36.  
  37.             double cost = nights * price;
  38.             if (earlyBooking10days)
  39.             {
  40.                 cost = nights * 25;
  41.             }
  42.  
  43.             if (earlyBooking1month)
  44.             {
  45.                 cost *= 0.8;
  46.             }
  47.  
  48.             Console.WriteLine($"Your stay from {checkInDay}/{checkInMonth} to {checkOutDay}/{checkOutMonth} will cost {cost:F2}");
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement