Advertisement
Tanina80

4_7_FruitShop_Dictionary_2

Jun 29th, 2016
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 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. else Console.WriteLine("error");
  28. }
  29. else if (day=="saturday" || day=="sunday")
  30. {
  31. price = quantity * pricesWeekend[fruit];
  32. Console.WriteLine("{0:f2}", price);
  33. else Console.WriteLine("error");
  34. }
  35. else
  36. {
  37. Console.WriteLine("error");
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement