Advertisement
plamen27

Fruit shop fixed final

Jun 27th, 2016
468
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 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. var stopops = 0;
  17. var price = 0.0;
  18.  
  19. if (day == "monday" || day == "tuesday" || day == "wednesday" || day == "thursday" || day == "friday")
  20. {
  21. if (fruit == "banana")
  22. {
  23. price = unit * 2.50;
  24. }
  25. else if (fruit == "apple")
  26. {
  27. price = unit * 1.20;
  28. }
  29. else if (fruit == "orange")
  30. {
  31. price = unit * 0.85;
  32. }
  33. else if (fruit == "grapefruit")
  34. {
  35. price = unit * 1.45;
  36. }
  37. else if (fruit == "kiwi")
  38. {
  39. price = unit * 2.70;
  40. }
  41. else if (fruit == "pineapple")
  42. {
  43. price = unit * 5.50;
  44. }
  45. else if (fruit == "grapes")
  46. {
  47. price = unit * 3.85;
  48. }
  49. else
  50. { Console.WriteLine("error"); stopops = 1; }
  51.  
  52. }
  53. else if (day == "saturday" || day == "sunday")
  54. {
  55. if (fruit == "banana")
  56. {
  57. price = unit * 2.70;
  58. }
  59. else if (fruit == "apple")
  60. {
  61. price = unit * 1.25;
  62. }
  63. else if (fruit == "orange")
  64. {
  65. price = unit * 0.90;
  66. }
  67. else if (fruit == "grapefruit")
  68. {
  69. price = unit * 1.60;
  70. }
  71. else if (fruit == "kiwi")
  72. {
  73. price = unit * 3.00;
  74. }
  75. else if (fruit == "pineapple")
  76. {
  77. price = unit * 5.60;
  78. }
  79. else if (fruit == "grapes")
  80. {
  81. price = unit * 4.20;
  82. }
  83. else
  84. { Console.WriteLine("error"); stopops = 1; }
  85. }
  86. else
  87. { Console.WriteLine("error"); stopops = 1; }
  88.  
  89. if (stopops == 0)
  90. { Console.WriteLine("{0:F2}", price); }
  91. if (stopops == 1)
  92. { Environment.Exit(0); }
  93.  
  94. }
  95. }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement