Krasimir_Slavov

Untitled

Nov 10th, 2018
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 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.  
  21. while (budget > spendMoney && (stock = Console.ReadLine()) != "stop")
  22. {
  23. double quantity = double.Parse(Console.ReadLine());
  24. double currentPrice = 0;
  25. switch (stock)
  26. {
  27. case "flowers": currentPrice = quantity * 1.5; flowers += quantity; break;
  28. case "balloons": currentPrice = quantity * 0.1; balloons += quantity; break;
  29. case "ribbon": currentPrice = quantity * 2; ribbon += quantity; break;
  30. case "candles": currentPrice = quantity * 0.5; candles += quantity; break;
  31. }
  32. spendMoney += currentPrice;
  33. }
  34. Console.WriteLine(budget <= spendMoney ? "All money is spent!" : $"Spend money: {spendMoney:F2}\nMoney left: {budget - spendMoney:F2}");
  35. Console.WriteLine("Purchased decoration is " + $"{balloons} balloons, {ribbon} m ribbon, {flowers} flowers and {candles} candles.");
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment