static void Main() { string[] input = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries); decimal pricePerDay = decimal.Parse(input[0]); int numOfDays = int.Parse(input[1]); string season = input[2]; string discountType = "none"; if (input.Length > 3) { discountType = input[3]; } decimal total = PriceCalculator.CalculatePrice(pricePerDay, numOfDays, Enum.Parse <Seasons>(season), Enum.Parse <Discount>(discountType)); Console.WriteLine($"{total:f2}"); }
static void Main(string[] args) { Console.WriteLine("Please enter the value following the formart (Price Per Day) (number of days) (season) (discount type):"); string[] inputTokens = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries); decimal pricePerDay = decimal.Parse(inputTokens[0]); int daysCount = int.Parse(inputTokens[1]); SeasonsPrice season = Enum.Parse <SeasonsPrice>(inputTokens[2]); Discount discount = Discount.None; if (inputTokens.Length == 4) { discount = Enum.Parse <Discount>(inputTokens[3]); } PriceCalculator priceCalculator = new PriceCalculator(pricePerDay, daysCount, season, discount); Console.WriteLine("The total price of the holiday is:"); priceCalculator.Calculate(Console.WriteLine); }
static void Main(string[] args) { var calc = new PriceCalculator(); var input = Console.ReadLine().Split(); var pricePerDay = decimal.Parse(input[0]); var days = int.Parse(input[1]); var season = Enum.Parse <Season>(input[2]); var discount = Discount.None; if (input.Length == 4) { discount = Enum.Parse <Discount>(input[3]); } var totalPrice = calc.Calculate(pricePerDay, days, season, discount); Console.WriteLine($"{totalPrice:f2}"); }
private static void Main() { List <string> items = Console.ReadLine() .Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries) .ToList(); decimal pricePerDay = decimal.Parse(items[0]); int numberOfDays = int.Parse(items[1]); Season season = (Season)Enum.Parse(typeof(Season), items[2]); DiscountType discountType = DiscountType.None; if (items.Count == 4) { discountType = (DiscountType)Enum.Parse(typeof(DiscountType), items[3]); } PriceCalculator calculator = new PriceCalculator(pricePerDay, numberOfDays, season, discountType); Console.WriteLine($"{calculator.CalculatePrice():F2}"); }
static void Main(string[] args) { var input = Console.ReadLine().Split(); Season season = Enum.Parse <Season>(input[2]); decimal finalPrice = 0; if (input.Length == 4) { Discount discount = Enum.Parse <Discount>(input[3]); finalPrice = PriceCalculator.CalculatePrice(decimal.Parse(input[0]), int.Parse(input[1]), season, discount); } else { finalPrice = PriceCalculator.CalculatePriceWithoutDiscount(decimal.Parse(input[0]), int.Parse(input[1]), season); } Console.WriteLine($"{finalPrice:f2}"); }
static void Main(string[] args) { string[] reservationDetails = Console.ReadLine() .Split(); decimal pricePerDay = decimal.Parse(reservationDetails[0]); int numberOfDays = int.Parse(reservationDetails[1]); string season = reservationDetails[2]; string discountType = null; try { discountType = reservationDetails[3]; } catch (Exception) { } PriceCalculator.CalculatePirce(pricePerDay, numberOfDays, season, discountType); Console.WriteLine($"{PriceCalculator.GetTotalPrice():F2}"); }
public static void Main(string[] args) { var inputInfo = Console.ReadLine() .Split(" ", StringSplitOptions.RemoveEmptyEntries); var pricePerDay = decimal.Parse(inputInfo[0]); var numberOfDays = int.Parse(inputInfo[1]); var season = inputInfo[2].ToLower(); var discountType = "none"; if (inputInfo.Length > 3) { discountType = inputInfo[3].ToLower(); } var calculator = new PriceCalculator(pricePerDay, numberOfDays); var calculatePrice = calculator.Calculate(Enum.Parse <Seasons>(season), Enum.Parse <Discount>(discountType)); Console.WriteLine($"{calculatePrice:F2}"); }
public static void Main() { string[] input = Console.ReadLine() .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries) .ToArray(); decimal pricePerDay = decimal.Parse(input[0]); int numberOfDays = int.Parse(input[1]); Season season = (Season)Enum.Parse(typeof(Season), input[2]); Discount discountType = Discount.None; if (input.Length == 4) { discountType = (Discount)Enum.Parse(typeof(Discount), input[3]); } PriceCalculator priceCalculator = new PriceCalculator(); decimal totalPrice = priceCalculator.GetTotalPrice(pricePerDay, numberOfDays, season, discountType); Console.WriteLine($"{totalPrice:F2}"); }
public static void Main() { string[] input = Console.ReadLine() .Split(' ', StringSplitOptions.RemoveEmptyEntries); decimal pricePerDay = decimal.Parse(input[0]); int days = int.Parse(input[1]); string season = input[2]; string discount = "None"; if (input.Length == 4) { discount = input[3]; } decimal price = PriceCalculator .GetTotalPrice(pricePerDay, days, Enum.Parse <Season>(season), Enum.Parse <Discount>(discount)); Console.WriteLine($"{price:f2}"); }
static void Main() { string[] input = Console.ReadLine() .Split(' '); var pricePerDay = decimal.Parse(input[0]); var numberOfDays = int.Parse(input[1]); var season = input[2]; var discountType = "None"; if (input.Length > 3) { discountType = input[3]; } PriceCalculator totalAmount = new PriceCalculator(pricePerDay, numberOfDays, Enum.Parse <Season>(season), Enum.Parse <DiscountType>(discountType)); var total = totalAmount.GetTotalPrice(); Console.WriteLine($"{total:f2}"); }
public static void Main() { string[] input = Console.ReadLine() .Split(" ", StringSplitOptions.RemoveEmptyEntries); decimal pricePerDay = decimal.Parse(input[0]); int numberOfDays = int.Parse(input[1]); string season = input[2]; string discountType = "None"; var currentSeason = Enum.Parse(typeof(Season), season); if (input.Length == 4) { discountType = input[3]; } var currentDiscount = Enum.Parse(typeof(Discount), discountType); decimal totalPrice = PriceCalculator.GetTotalPrice(pricePerDay, numberOfDays, (Season)currentSeason, (Discount)currentDiscount); Console.WriteLine($"{totalPrice:F2}"); }
public static void Main(string[] args) { string[] input = Console.ReadLine().Split(); // if (input.Length == 4) { decimal price = decimal.Parse(input[0]); int days = int.Parse(input[1]); var sea = input[2]; var dis = input[3]; Enum.TryParse(sea, out Season season); Enum.TryParse(dis, out Discount discount); var resulT = PriceCalculator.Calculate(price, days, season, discount); Console.WriteLine($"{resulT:f2}"); } else { decimal price = decimal.Parse(input[0]); int days = int.Parse(input[1]); Enum.TryParse(input[2], out Season season); var resulT = PriceCalculator.CalculateS(price, days, season); Console.WriteLine($"{resulT:f2}"); } }
static void Main(string[] args) { var input = Console.ReadLine().Split(); decimal pricePerDay = decimal.Parse(input[0]); int numberOfDays = int.Parse(input[1]); string seasonData = input[2]; string discountType = ""; if (input.Length == 3) { discountType = "None"; } else { discountType = input[3]; } decimal price = PriceCalculator.CalculatePrice( pricePerDay, numberOfDays, Enum.Parse <Season>(seasonData), Enum.Parse <Discount>(discountType)); Console.WriteLine($"{price:F2}"); }
public static void Main(string[] args) { string[] input = Console.ReadLine() .Split(" ", StringSplitOptions.RemoveEmptyEntries); if (input.Length == 4) { double pricePerDay = double.Parse(input[0]); int daysCount = int.Parse(input[1]); string season = input[2]; string discountType = input[3]; double price = PriceCalculator.Calculate(pricePerDay, daysCount, season, discountType); Console.WriteLine($"{price:f2}"); } else if (input.Length == 3) { double pricePerDay = double.Parse(input[0]); int daysCount = int.Parse(input[1]); string season = input[2]; double price = PriceCalculator.Calculate(pricePerDay, daysCount, season); Console.WriteLine($"{price:f2}"); } }
static void Main(string[] args) { System.Console.WriteLine(PriceCalculator.Calculate(10, 5, Season.Summer, Discount.SecondVisit)); }
public static void Main() { string[] input = Console.ReadLine() .Split() .ToArray(); double pricePerDay = double.Parse(input[0]); int numberOfDays = int.Parse(input[1]); Season season = new Season(); Discount discount = new Discount(); string seasonType = input[2]; switch (seasonType) { case "Summer": season = (Season)4; break; case "Winter": season = (Season)3; break; case "Autumn": season = (Season)1; break; case "Spring": season = (Season)2; break; default: break; } if (input.Length == 3) { string discountType = input[3]; switch (discountType) { case "None": break; case "SecondVisit": discount = (Discount)10; break; case "VIP": discount = (Discount)20; break; default: break; } } PriceCalculator calculator = new PriceCalculator(); double finalPrice = calculator.CalculatePrice(pricePerDay, numberOfDays, season, discount); Console.WriteLine($"{finalPrice:f2}"); }
public static void Main(string[] args) { var hotelPriceCalculator = PriceCalculator.CalculatePrice(75, 5, Season.Summer, DiscountType.None); Console.WriteLine(hotelPriceCalculator); }
static void Main(string[] args) { Console.WriteLine(PriceCalculator.CalculatePrice(Console.ReadLine())); }
public static void Main(string[] args) { var priceCalculator = new PriceCalculator(Console.ReadLine); Console.WriteLine(priceCalculator.CalculatePrice()); }
static void Main(string[] args) { var calculator = new PriceCalculator(Console.ReadLine); Console.WriteLine($"{calculator.Calculate():F2}"); }