Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 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 balloonPrice = 0.1;
  10. double flowerPrice = 1.5;
  11. double candlePrice = 0.5;
  12. double ribbonPrice = 2.0;
  13. int balloonsCount = 0;
  14. int ribbonCount = 0;
  15. int flowersCount = 0;
  16. int candlesCount = 0;
  17. double spendMoney = 0;
  18.  
  19.  
  20.  
  21. double budget = double.Parse(Console.ReadLine());
  22. string input = Console.ReadLine();
  23. while (input != "stop")
  24. {
  25.  
  26. int decorationAmount = int.Parse(Console.ReadLine());
  27. if (input == "balloons")
  28. {
  29. balloonsCount += decorationAmount;
  30. spendMoney += balloonPrice * decorationAmount;
  31.  
  32. }
  33. else if (input == "ribbon")
  34. {
  35. ribbonCount += decorationAmount;
  36. spendMoney += ribbonPrice * decorationAmount;
  37. }
  38. else if (input == "flowers")
  39. {
  40. flowersCount += decorationAmount;
  41. spendMoney += flowerPrice * decorationAmount;
  42.  
  43. }
  44. else if (input == "candles")
  45. {
  46. candlesCount += decorationAmount;
  47. spendMoney += candlePrice * decorationAmount;
  48.  
  49. }
  50.  
  51.  
  52.  
  53.  
  54. if (spendMoney >= budget)
  55. {
  56. Console.WriteLine("All money is spent!");
  57. break;
  58.  
  59. }
  60.  
  61.  
  62.  
  63. input = Console.ReadLine();
  64. }
  65. if (input == "stop")
  66. {
  67.  
  68. Console.WriteLine($"Spend money: {spendMoney:f2}");
  69. Console.WriteLine($"Money left: {(budget - spendMoney):f2}");
  70.  
  71.  
  72.  
  73. }
  74.  
  75.  
  76. Console.WriteLine($"Purchased decoration is {balloonsCount} balloons, {ribbonCount} m ribbon, {flowersCount} flowers and {candlesCount} candles.");
  77.  
  78. }
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement