Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp1
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. double budget = double.Parse(Console.ReadLine());
  10.  
  11. double priceStar = 5.69;
  12. double priceAngel = 8.49;
  13. double priceLights = 11.20;
  14. double priceWreath = 15.50;
  15. double priceCandel = 3.59;
  16.  
  17. int count = 0;
  18. double spendMoney = 0;
  19. double needMoney = 0;
  20.  
  21. bool isFinish = false;
  22.  
  23. while (true)
  24. {
  25. string item = Console.ReadLine();
  26.  
  27. double curentPrice = 0;
  28.  
  29. if (item == "Finish")
  30. {
  31. isFinish = true;
  32.  
  33. break;
  34. }
  35.  
  36. if (item == "Star")
  37. {
  38. curentPrice = priceStar;
  39. }
  40. else if (item == "Angel")
  41. {
  42. curentPrice = priceAngel;
  43. }
  44. else if (item == "Lights")
  45. {
  46. curentPrice = priceLights;
  47. }
  48. else if (item == "Wreath")
  49. {
  50. curentPrice = priceWreath;
  51. }
  52. else if (item == "Candle")
  53. {
  54. curentPrice = priceCandel;
  55.  
  56. }
  57.  
  58. count++;
  59.  
  60. if (count % 3 == 0)
  61. {
  62. curentPrice -= curentPrice * 0.3;
  63. }
  64.  
  65. if (budget < curentPrice)
  66. {
  67. needMoney = curentPrice - budget;
  68.  
  69. break;
  70. }
  71.  
  72.  
  73. budget -= curentPrice;
  74. spendMoney += curentPrice;
  75. }
  76.  
  77. if (isFinish)
  78. {
  79. Console.WriteLine("Congratulations! You bought everything!");
  80. }
  81. else
  82. {
  83. Console.WriteLine($"Not enough money! You need {needMoney:F2}lv more.");
  84. }
  85.  
  86. Console.WriteLine($"{count} items -> {spendMoney:F2}lv spent.");
  87. }
  88. }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement