Advertisement
aleksiev2002

Untitled

Dec 15th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. using System;
  2.  
  3. namespace WeddingDecoration
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. double budget = double.Parse(Console.ReadLine());
  10. double baloons = 0.1;
  11. double flowers = 1.5;
  12. double candles = 0.5;
  13. double ribbon = 2;
  14.  
  15. double currentMoneyCount = budget;
  16.  
  17.  
  18. int baloonCount = 0;
  19. int flowerCount = 0;
  20. int candleCount = 0;
  21. int ribbonCount = 0;
  22. bool stop = false;
  23.  
  24.  
  25. while (currentMoneyCount > 0)
  26. {
  27. double orderSum = 0;
  28. int orders = int.Parse(Console.ReadLine());
  29. string stockType = Console.ReadLine();
  30.  
  31.  
  32. if (stockType == "balloons")
  33. {
  34. orderSum = orders * baloons;
  35. baloonCount += orders;
  36. }
  37. else if (stockType == "flowers")
  38. {
  39. orderSum = orders * flowers;
  40. flowerCount += orders;
  41. }
  42. else if (stockType == "candles")
  43. {
  44. orderSum = orders * candles;
  45. candleCount += orders;
  46. }
  47. else if (stockType == "ribbon")
  48. {
  49. orderSum = orders * ribbon;
  50. ribbonCount += orders;
  51.  
  52. }
  53. else if (stockType == "stop")
  54. {
  55. stop = true;
  56. break;
  57. }
  58. currentMoneyCount -= orderSum;
  59.  
  60. }
  61.  
  62. if (stop)
  63. {
  64. Console.WriteLine($"Spend money: {budget - currentMoneyCount}");
  65. Console.WriteLine($"Money left: {currentMoneyCount:f2}");
  66. Console.WriteLine($"Purchased decoration is {baloonCount} balloons, {ribbonCount} m ribbon, {flowerCount} flowers and {candleCount} candles.");
  67. }
  68. else
  69. {
  70. Console.WriteLine("All money is spent!");
  71. Console.WriteLine($"Purchased decoration is {baloonCount} balloons, {ribbonCount} m ribbon, {flowerCount} flowers and {candleCount} candles.");
  72. }
  73.  
  74.  
  75.  
  76. }
  77.  
  78.  
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement