Krasimir_Slavov

Untitled

Nov 4th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 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 Exam_Wedding_Decoration
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. double budget = double.Parse(Console.ReadLine());
  14. double ribbon = 0;
  15. double balloons = 0;
  16. double flowers = 0;
  17. double candles = 0;
  18. string stock = string.Empty;
  19. double spendMoney = 0;
  20. while (budget > spendMoney && (stock = Console.ReadLine()) != "stop")
  21. {
  22. double quantity = double.Parse(Console.ReadLine());
  23. double currentPrice = 0;
  24. switch (stock)
  25. {
  26. case "flowers": currentPrice = quantity * 1.5; flowers += quantity; break;
  27. case "balloons": currentPrice = quantity * 0.1; balloons += quantity; break;
  28. case "ribbon": currentPrice = quantity * 2; ribbon += quantity; break;
  29. case "candles": currentPrice = quantity * 0.5; candles += quantity; break;
  30. }
  31. spendMoney += currentPrice;
  32. }
  33. Console.WriteLine(budget <= spendMoney ?
  34. "All money is spent!" :
  35. $"Spend money: {spendMoney:F2}\nMoney left: {budget - spendMoney:F2}");
  36. Console.WriteLine("Purchased decoration is " +
  37. $"{balloons} balloons, {ribbon} m ribbon, {flowers} flowers and {candles} candles.");
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment