angelllo

Почивка full code

Mar 10th, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp14
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. double neededMoney = double.Parse(Console.ReadLine());
  10. double availableMoney = double.Parse(Console.ReadLine());
  11. int daysCounter = 0;
  12. int counterSpend = 0;
  13.  
  14. while (availableMoney < neededMoney)
  15. {
  16. string command = Console.ReadLine();
  17. double operationalMoney = double.Parse(Console.ReadLine());
  18. daysCounter++;
  19.  
  20. if (command == "spend")
  21. {
  22. counterSpend++;
  23. availableMoney -= operationalMoney;
  24. if (counterSpend == 5)
  25. {
  26. Console.WriteLine($"You can't save the money.");
  27. Console.WriteLine($"{daysCounter}");
  28. break;
  29. }
  30.  
  31. if (availableMoney < 0)
  32. {
  33. availableMoney = 0;
  34. }
  35. }
  36. else if (command == "save")
  37. {
  38. availableMoney += operationalMoney;
  39. }
  40. }
  41. if (availableMoney >= neededMoney)
  42. {
  43. Console.WriteLine($"You saved the money for {daysCounter} days.");
  44. }
  45.  
  46. }
  47. }
  48. }
Add Comment
Please, Sign In to add comment