Advertisement
elena1234

Hotel Reservation - enumeration

Mar 16th, 2021
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.90 KB | None | 0 0
  1. sing System;
  2.  
  3. namespace HotelReservation
  4. {
  5.     public class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string[] input = Console.ReadLine().Split();
  10.             decimal price = decimal.Parse(input[0]);
  11.             int numberOfDays = int.Parse(input[1]);
  12.             Season season = Enum.Parse<Season>(input[2]);
  13.  
  14.             decimal totalPrice = 0;
  15.             if (input.Length == 4)
  16.             {
  17.                 DiscountType discount = Enum.Parse<DiscountType>(input[3]);
  18.                 totalPrice = PriceCalcualtor.GetTotalPrice(price, numberOfDays, season, discount);
  19.             }
  20.  
  21.             else
  22.             {
  23.                 DiscountType discount = DiscountType.None;
  24.                 totalPrice = PriceCalcualtor.GetTotalPrice(price, numberOfDays, season, discount);
  25.             }
  26.  
  27.             Console.WriteLine($"{totalPrice:f2}");
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement