Advertisement
Guest User

Hotel reservation

a guest
Jul 3rd, 2019
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. namespace P04HotelReservation
  6. {
  7.     public class PriceCalculator
  8.     {
  9.         public static decimal CalculatePrice(decimal pricePerDay, int numberOfDays, Season season, Discount discount = 0)
  10.         {
  11.             int multiplier = (int)season;
  12.             decimal discountMultiplier = (decimal)discount / 100;
  13.             decimal priceBeforeDiscount = numberOfDays * pricePerDay * multiplier;
  14.             decimal discountedAmount =
  15.                          priceBeforeDiscount * discountMultiplier;
  16.             decimal finalPrice = priceBeforeDiscount - discountedAmount;
  17.  
  18.             return finalPrice;
  19.         }
  20.     }
  21.  
  22.     public enum Season
  23.     {
  24.         Spring = 2,
  25.         Summer = 4,
  26.         Autumn = 1,
  27.         Winter = 3
  28.     }
  29.  
  30.     public enum Discount
  31.     {
  32.         None,
  33.         SecondVisit = 10,
  34.         VIP = 20
  35.     }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement