Guest User

07. Fruit Shop

a guest
Jun 27th, 2016
1,233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _07.FruitShop
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. string fruit = Console.ReadLine().ToLower();
  14. string day = Console.ReadLine().ToLower();
  15. var unit = double.Parse(Console.ReadLine());
  16.  
  17. var price = -1.0;
  18.  
  19. if (day == "monday" || day == "tuesday" || day == "wednesdy" || day == "thursday" || day == "friday")
  20. {
  21. if (fruit == "banana")
  22. {
  23. price = 2.50;
  24. }
  25. else if (fruit == "apple")
  26. {
  27. price = 1.20;
  28. }
  29. else if (fruit == "orange")
  30. {
  31. price = 0.85;
  32. }
  33. else if (fruit == "grapefruit")
  34. {
  35. price = 1.45;
  36. }
  37. else if (fruit == "kiwi")
  38. {
  39. price = 2.70;
  40. }
  41. else if (fruit == "pineapple")
  42. {
  43. price = 5.50;
  44. }
  45. else if (fruit == "grapes")
  46. {
  47. price = 3.85;
  48. }
  49.  
  50. }
  51. if (day == "saturday " || day == "sunday")
  52. {
  53. if (fruit == "banana")
  54. {
  55. price = 2.70;
  56. }
  57. else if (fruit == "apple")
  58. {
  59. price = 1.25;
  60. }
  61. else if (fruit == "orange")
  62. {
  63. price = 0.90;
  64. }
  65. else if (fruit == "arapefruit")
  66. {
  67. price = 1.60;
  68. }
  69. else if (fruit == "kiwi")
  70. {
  71. price = 3.00;
  72. }
  73. else if (fruit == "pineapple")
  74. {
  75. price = 5.60;
  76. }
  77. else if (fruit == "grapes")
  78. {
  79. price = 4.20;
  80. }
  81. }
  82. if (price >= 0)
  83. {
  84. Console.WriteLine("{0:F2}", price * unit);
  85. }
  86. else
  87. {
  88. Console.WriteLine("error");
  89. }
  90.  
  91.  
  92.  
  93. }
  94. }
  95. }
Advertisement
Add Comment
Please, Sign In to add comment