Advertisement
Tanina80

4_7_FruitShop_Dictionary

Jun 29th, 2016
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4.  
  5. class FruitShop
  6. {
  7. static void Main()
  8. {
  9. var fruit = Console.ReadLine().ToLower();
  10. var day = Console.ReadLine().ToLower();
  11. var quantity = double.Parse(Console.ReadLine());
  12. var price = -1.0;
  13.  
  14. Dictionary<string, double> pricesWeek = new Dictionary<string, double>
  15. { { "banana", 2.50 }, { "apple",1.20}, { "orange",0.85},
  16. {"grapefruit",1.45}, {"kiwi",2.70}, { "pineapple",5.50}, { "grapes",3.85}
  17. };
  18. Dictionary<string, double> pricesWeekend = new Dictionary<string, double>
  19. { { "banana", 2.70 }, { "apple",1.25}, { "orange",0.90},
  20. {"grapefruit",1.60}, {"kiwi",3.00}, { "pineapple",5.60}, { "grapes",4.20}
  21. };
  22.  
  23. if (day == "monday" || day == "tuesday" || day == "wednesday" || day == "thirsday" || day == "friday")
  24. {
  25. price = quantity * pricesWeek[fruit];
  26. Console.WriteLine("{0:f2}", price);
  27. }
  28. else if (day=="saturday" || day=="sunday")
  29. {
  30. price = quantity * pricesWeekend[fruit];
  31. Console.WriteLine("{0:f2}", price);
  32. }
  33. else
  34. {
  35. Console.WriteLine("error");
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement