Advertisement
spasnikolov131

Untitled

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