VickSuna

Untitled

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