Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace ConsoleApp4
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. var fruit = Console.ReadLine();
  12. var dayOfWeek = Console.ReadLine();
  13. var calculation = double.Parse(Console.ReadLine());
  14.  
  15. string[] workdaysDays = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" };
  16. string[] weekendDays = { "Saturday", "Sunday" };
  17.  
  18. Dictionary<string, double> workdays = new Dictionary<string, double>();
  19. workdays.Add("banana", 2.50);
  20. workdays.Add("apple", 1.20);
  21. workdays.Add("orange", 0.85);
  22. workdays.Add("grapefruit", 1.45);
  23. workdays.Add("kiwi", 2.70);
  24. workdays.Add("pineapple", 5.50);
  25. workdays.Add("grapes", 3.85);
  26. Dictionary<string, double> weekend = new Dictionary<string, double>();
  27. weekend.Add("banana", 2.70);
  28. weekend.Add("apple", 1.25);
  29. weekend.Add("orange", 0.90);
  30. weekend.Add("grapefruit", 1.60);
  31. weekend.Add("kiwi", 3.00);
  32. weekend.Add("pineapple", 5.60);
  33. weekend.Add("grapes", 4.20);
  34.  
  35. if (workdaysDays.Any(dayOfWeek.Contains))
  36. {
  37. try
  38. {
  39. var price = workdays[fruit];
  40. Console.WriteLine($"{price*calculation:f2}");
  41. }
  42. catch (Exception)
  43. {
  44. Console.WriteLine("error");
  45. }
  46. }
  47. else if(weekendDays.Any(dayOfWeek.Contains))
  48. {
  49. try
  50. {
  51. var price = weekend[fruit];
  52. Console.WriteLine($"{price * calculation:f2}");
  53. }
  54. catch (Exception)
  55. {
  56. Console.WriteLine("error");
  57. }
  58. }
  59. else
  60. {
  61. Console.WriteLine("error");
  62. }
  63. }
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement