Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace FruitShop
- {
- class FruitShop
- {
- static void Main(string[] args)
- {
- var product = Console.ReadLine();
- var day = Console.ReadLine();
- var quantity = double.Parse(Console.ReadLine());
- var workDays = new HashSet<string>()
- {
- "Monday","Tuesday","Wednesday","Thursday","Friday"
- };
- var weekend = new HashSet<string>()
- {
- "Saturday","Sunday"
- };
- var workDayPricing = FillPricing(2.50, 1.20, 0.85, 1.45, 2.70, 5.50, 3.85);
- var weekendPricing = FillPricing(2.70, 1.25, 0.90, 1.60, 3.00, 5.60, 4.20);
- if (workDays.Contains(day))
- {
- if (workDayPricing.ContainsKey(product))
- {
- Console.WriteLine("{0:F2}", workDayPricing[product] * quantity);
- }
- else
- {
- Console.WriteLine("error");
- }
- }
- else if (weekend.Contains(day))
- {
- if (weekendPricing.ContainsKey(product))
- {
- Console.WriteLine("{0:F2}", weekendPricing[product] * quantity);
- }
- else
- {
- Console.WriteLine("error");
- }
- }
- else
- {
- Console.WriteLine("error");
- }
- }
- private static Dictionary<string, double> FillPricing(double d1, double d2, double d3,
- double d4, double d5, double d6, double d7)
- {
- var pricing = new Dictionary<string, double>();
- pricing.Add("banana", d1);
- pricing.Add("apple", d2);
- pricing.Add("orange", d3);
- pricing.Add("grapefruit", d4);
- pricing.Add("kiwi", d5);
- pricing.Add("pineapple", d6);
- pricing.Add("grapes", d7);
- return pricing;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement