Advertisement
Guest User

ss

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