BallistixXx

FruitShop

Jul 29th, 2017
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.72 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace FruitShop
  5. {
  6.     class Program
  7.     {
  8.         static void Main()
  9.         {
  10.             string Fruit = Console.ReadLine().ToLower();
  11.             string Day = Console.ReadLine().ToLower();
  12.             double Amount = double.Parse(Console.ReadLine());
  13.  
  14.             Enum DaysOfWeek = new DayOfWeek();
  15.             Dictionary<string, List<double>> PriceList = new Dictionary<string, List<double>>()
  16.             {
  17.                     { "banana", new List<double>(){2.50,2.70}},
  18.                     { "apple", new List<double>(){1.20,1.25}},
  19.                     { "orange", new List<double>(){0.85,0.90}},
  20.                     { "grapefruit", new List<double>(){1.45,1.60}},
  21.                     { "kiwi", new List<double>(){2.70,3.00}},
  22.                     { "pineapple", new List<double>(){5.50,5.60}},
  23.                     { "grapes", new List<double>(){3.85,4.20}}
  24.             };
  25.             try
  26.             {
  27.                 DaysOfWeek = (DayOfWeek)Enum.Parse(typeof(DayOfWeek), Day.Replace(Day[0], Char.ToUpper(Day[0])));
  28.             }
  29.             catch
  30.             {
  31.                 Console.WriteLine("error");
  32.                 return;
  33.             }  
  34.             if (PriceList.ContainsKey(Fruit))
  35.             {
  36.                 if (DaysOfWeek.ToString() == "Saturday" || DaysOfWeek.ToString() == "Sunday")
  37.                 {
  38.                     Console.WriteLine(Math.Round(Amount * PriceList[Fruit][1], 2));
  39.                 }
  40.                 else
  41.                 {
  42.                     Console.WriteLine(Math.Round(Amount * PriceList[Fruit][0], 2));
  43.                 }
  44.             }
  45.             else
  46.                 Console.WriteLine("error");
  47.         }
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment