Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. using System;
  2.  
  3. class MainClass {
  4. public static void Main (string[] args)
  5. {
  6. double inheritance = double.Parse(Console.ReadLine());
  7. int year = int.Parse(Console.ReadLine());
  8. double counter = 0;
  9. double totalSpent = 0;
  10.  
  11. for (int i = 1800; i <= year; i++)
  12. {
  13. counter++;
  14. double yearsAddition = 50 * (18 + (counter/2));
  15. double evenYear = 12000;
  16. double oddYear = 12000 + yearsAddition;
  17.  
  18. if (i % 2 != 0)
  19. {
  20. totalSpent += oddYear;
  21. }
  22. else
  23. {
  24. totalSpent += evenYear;
  25. }
  26. }
  27. if (inheritance >= totalSpent)
  28. {
  29. Console.WriteLine($"Yes! He will live a carefree life and will have {(inheritance - totalSpent):F2} dollars left.");
  30. }
  31. else
  32. {
  33. Console.WriteLine($"He will need {Math.Abs(inheritance - totalSpent):F2} dollars to survive.");
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement