Advertisement
veselka_a

2.Reservation

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