Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _02.Reservation
- {
- class Reservation
- {
- static void Main(string[] args)
- {
- int dayNow = int.Parse(Console.ReadLine());
- int monthNow = int.Parse(Console.ReadLine());
- int checkInDay = int.Parse(Console.ReadLine());
- int checkInMonth = int.Parse(Console.ReadLine());
- int checkOutDay = int.Parse(Console.ReadLine());
- int checkOutMonth = int.Parse(Console.ReadLine());
- int nights = checkOutDay - checkInDay;
- int daysApart = Math.Abs(dayNow - checkInDay);
- int monthsApart = Math.Abs(monthNow - checkInMonth);
- bool earlyBooking10days = false;
- bool earlyBooking1month = false;
- double price = 30;
- if (daysApart >= 10)
- {
- earlyBooking10days = true;
- }
- if (monthsApart >= 1)
- {
- earlyBooking1month = true;
- earlyBooking10days = true;
- }
- double cost = nights * price;
- if (earlyBooking10days)
- {
- cost = nights * 25;
- }
- if (earlyBooking1month)
- {
- cost = cost * 0.8;
- }
- Console.WriteLine($"Your stay from {checkInDay}/{checkInMonth} to {checkOutDay}/{checkOutMonth} will cost {cost:F2}");
- }
- }
- }
Add Comment
Please, Sign In to add comment