Advertisement
KrasenPenev

Vacantion

Feb 10th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 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 Vacation_1._0
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. double neededMoney = double.Parse(Console.ReadLine());
  14. double balance = double.Parse(Console.ReadLine());
  15. double dayCounter = 0;
  16.  
  17.  
  18. while (neededMoney>=balance)
  19. {
  20. string spendOrSave = Console.ReadLine();
  21. double moneyForSpendOrSave = double.Parse(Console.ReadLine());
  22.  
  23. dayCounter++;
  24.  
  25. if (spendOrSave=="spend")
  26. {
  27. balance -= moneyForSpendOrSave;
  28. if (balance<=0)
  29. {
  30. balance = 0;
  31. }
  32. if (dayCounter==5)
  33. {
  34. Console.WriteLine($"You can't save the money.");
  35. Console.WriteLine($"{dayCounter}");
  36. break;
  37. }
  38.  
  39. }
  40. else if (spendOrSave=="save")
  41. {
  42. balance += moneyForSpendOrSave;
  43. }
  44. if (balance==neededMoney)
  45. {
  46. Console.WriteLine($"You saved the money for {dayCounter} days.");
  47. break;
  48. }
  49.  
  50.  
  51. }
  52. }
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement