Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace FruitShop
- {
- class Program
- {
- static void Main()
- {
- string Fruit = Console.ReadLine().ToLower();
- string Day = Console.ReadLine().ToLower();
- double Amount = double.Parse(Console.ReadLine());
- Enum DaysOfWeek = new DayOfWeek();
- Dictionary<string, List<double>> PriceList = new Dictionary<string, List<double>>()
- {
- { "banana", new List<double>(){2.50,2.70}},
- { "apple", new List<double>(){1.20,1.25}},
- { "orange", new List<double>(){0.85,0.90}},
- { "grapefruit", new List<double>(){1.45,1.60}},
- { "kiwi", new List<double>(){2.70,3.00}},
- { "pineapple", new List<double>(){5.50,5.60}},
- { "grapes", new List<double>(){3.85,4.20}}
- };
- try
- {
- DaysOfWeek = (DayOfWeek)Enum.Parse(typeof(DayOfWeek), Day.Replace(Day[0], Char.ToUpper(Day[0])));
- }
- catch
- {
- Console.WriteLine("error");
- return;
- }
- if (PriceList.ContainsKey(Fruit))
- {
- if (DaysOfWeek.ToString() == "Saturday" || DaysOfWeek.ToString() == "Sunday")
- {
- Console.WriteLine(Math.Round(Amount * PriceList[Fruit][1], 2));
- }
- else
- {
- Console.WriteLine(Math.Round(Amount * PriceList[Fruit][0], 2));
- }
- }
- else
- Console.WriteLine("error");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment