YavorJS

Back To The Past

Jul 19th, 2016
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. class Program
  5. {
  6. static void Main()
  7. {
  8. decimal inheritance = decimal.Parse(Console.ReadLine());
  9. int endYear = int.Parse(Console.ReadLine());
  10. decimal expences = 0m;
  11. decimal remainingSum = 0m;
  12. int yearsIvan = 18;
  13.  
  14. for (int i = 1800; i <= endYear; i++)
  15. {
  16. if (i%2==0)
  17. {
  18. if (i>1800)
  19. {
  20. inheritance = remainingSum;
  21. }
  22. expences = 12000;
  23. remainingSum = inheritance - expences;
  24. }
  25. else
  26. {
  27. expences = 12000 + yearsIvan * 50;
  28. remainingSum = remainingSum - expences;
  29. }
  30. yearsIvan++;
  31. }//end of for
  32. if (remainingSum>=0)
  33. {
  34. Console.WriteLine($"Yes! He will live a carefree life and will have {remainingSum:f2} dollars left.");
  35. }
  36. else
  37. {
  38. Console.WriteLine($"He will need {-remainingSum:f2} dollars to survive.");
  39. }
  40.  
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment