Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.00 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp1
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. string command = "";
  10.  
  11.  
  12. double sumMonets = 0;
  13. double restMoney = 0;
  14. double monets1 = 0;
  15. double sumMonetsCanNotAccepts = 0;
  16. double sumNotEnoughtMoney = 0;
  17.  
  18. int counterCannotAccept = 0;
  19. int counterNevalidenProduct = 0;
  20. int counterCoke = 0;
  21. int counterNuts = 0;
  22. int counterWater = 0;
  23. int counterCrisps = 0;
  24. int counterSoda = 0;
  25. int counterNotEnoughtMoney = 0;
  26.  
  27. double sumCoke = 0;
  28. double sumNuts = 0;
  29. double sumWater = 0;
  30. double sumCrisps = 0;
  31. double sumSoda = 0;
  32.  
  33.  
  34.  
  35.  
  36. while (command != "Start")
  37. {
  38. string monets = Console.ReadLine();
  39.  
  40. if (monets == "Start")
  41. {
  42. break;
  43. }
  44.  
  45. monets1 = double.Parse(monets);
  46.  
  47. if (monets1 == 0.1 || monets1 == 0.2 || monets1 == 0.5 || monets1 == 1 || monets1 == 2)
  48. {
  49. sumMonets += monets1;
  50. }
  51.  
  52. else
  53. {
  54. counterCannotAccept++;
  55. sumMonetsCanNotAccepts = monets1;
  56. }
  57.  
  58. }
  59.  
  60.  
  61.  
  62. string products = "";
  63.  
  64. while (products != "End")
  65. {
  66. products = Console.ReadLine();
  67.  
  68. if (products == "Coke")
  69. {
  70. if (sumMonets < 1.00)
  71. {
  72. counterNotEnoughtMoney++;
  73. sumNotEnoughtMoney = 1.00 - sumMonets;
  74. continue;
  75.  
  76. }
  77.  
  78. counterCoke++;
  79. sumCoke = 1.00 * counterCoke;
  80. sumMonets -= sumCoke;
  81.  
  82. }
  83.  
  84. else if (products == "Nuts")
  85. {
  86. if (sumMonets < 2.00)
  87. {
  88. counterNotEnoughtMoney++;
  89. sumNotEnoughtMoney = 2.00 - sumMonets;
  90. continue;
  91.  
  92.  
  93.  
  94. }
  95. counterNuts++;
  96. sumNuts = 2.00 * counterNuts;
  97. sumMonets -= sumNuts;
  98.  
  99. }
  100.  
  101. else if (products == "Water")
  102. {
  103. if (sumMonets < 0.70)
  104. {
  105. counterNotEnoughtMoney++;
  106. sumNotEnoughtMoney = 0.70 - sumMonets;
  107. continue;
  108.  
  109. }
  110.  
  111. counterWater++;
  112. sumWater = 0.70 * counterWater;
  113. sumMonets -= sumWater;
  114.  
  115. }
  116.  
  117. else if (products == "Crisps")
  118. {
  119. if (sumMonets < 1.50)
  120. {
  121. counterNotEnoughtMoney++;
  122. sumNotEnoughtMoney = 1.50 - sumMonets;
  123. continue;
  124.  
  125. }
  126.  
  127. counterCrisps++;
  128. sumCrisps = 1.50 * counterCrisps;
  129. sumMonets -= sumCrisps;
  130.  
  131. }
  132.  
  133. else if (products == "Soda")
  134. {
  135.  
  136. if (sumMonets < 0.80)
  137. {
  138. counterNotEnoughtMoney++;
  139. sumNotEnoughtMoney = 0.80 - sumMonets;
  140. continue;
  141.  
  142. }
  143.  
  144. counterSoda++;
  145. sumSoda = 0.80 * counterSoda;
  146. sumMonets -= sumSoda;
  147.  
  148. }
  149.  
  150. else if (products == "End")
  151. {
  152. break;
  153. }
  154.  
  155. else
  156. {
  157. counterNevalidenProduct++;
  158. }
  159.  
  160. }
  161.  
  162.  
  163.  
  164.  
  165. if (counterCannotAccept > 0)
  166. {
  167. for (int i = 0; i < counterCannotAccept; i++)
  168. {
  169. Console.WriteLine($"Cannot accept {sumMonetsCanNotAccepts}");
  170. }
  171. }
  172.  
  173.  
  174. if (counterNevalidenProduct > 0)
  175. {
  176. for (int i = 0; i < counterNevalidenProduct; i++)
  177. {
  178. Console.WriteLine("Invalid product");
  179. }
  180.  
  181. }
  182.  
  183.  
  184.  
  185. if (counterCoke > 0)
  186. {
  187. for (int i = 0; i < counterCoke; i++)
  188. {
  189. Console.WriteLine("Purchased coke");
  190. }
  191. }
  192.  
  193. if (counterWater > 0)
  194. {
  195. for (int i = 0; i < counterWater; i++)
  196. {
  197. Console.WriteLine("Purchased water");
  198. }
  199.  
  200. }
  201.  
  202. if (counterCrisps > 0)
  203. {
  204. for (int i = 0; i < counterCrisps; i++)
  205. {
  206. Console.WriteLine("Purchased crisps");
  207. }
  208.  
  209. }
  210.  
  211. if (counterSoda > 0)
  212. {
  213. for (int i = 0; i < counterSoda; i++)
  214. {
  215. Console.WriteLine("Purchased soda");
  216. }
  217. }
  218.  
  219. if (counterNuts > 0)
  220. {
  221. for (int i = 0; i < counterNuts; i++)
  222. {
  223. Console.WriteLine("Purchased nuts");
  224. }
  225. }
  226.  
  227.  
  228. if (counterNotEnoughtMoney > 0)
  229. {
  230. for (int i = 0; i < counterNotEnoughtMoney; i++)
  231. {
  232. Console.WriteLine("Sorry, not enough money");
  233. }
  234.  
  235. }
  236.  
  237.  
  238.  
  239. Console.WriteLine($"Change: {Math.Abs(sumMonets):f2}");
  240.  
  241. }
  242. }
  243. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement