Advertisement
aggressiveviking

01._Back_To_The_Past

Feb 5th, 2020
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _01._Back_To_The_Past
  4. {
  5. class BackToThePast
  6. {
  7. static void Main(string[] args)
  8. {
  9. double inheritence = double.Parse(Console.ReadLine());
  10. int life = int.Parse(Console.ReadLine());
  11.  
  12. int age = 18;
  13. int yearStart = 1800;
  14. int yearsToLive = life - yearStart;
  15.  
  16.  
  17. for (int i = 0; i <= yearsToLive; i++)
  18. {
  19. if (yearStart % 2 == 0)
  20. {
  21. inheritence = inheritence - 12000;
  22. yearStart = yearStart + 1;
  23. age = age + 1;
  24. }
  25. else if (yearStart % 2 != 0)
  26. {
  27. inheritence = inheritence - (12000 + 50 * age);
  28. yearStart = yearStart + 1;
  29. age = age + 1;
  30. }
  31. }
  32.  
  33. if (inheritence >= 0)
  34. {
  35. Console.WriteLine("Yes! He will live a carefree life and will have " + $"{inheritence:f2}" + " dollars left.");
  36. }
  37. else
  38. {
  39. inheritence = Math.Abs(inheritence);
  40. Console.WriteLine("He will need " + $"{inheritence:f2}" + " dollars to survive.");
  41. }
  42. }
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement