kotunec

Back to the past /SoftUni/

Aug 7th, 2016
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Back_To_The_Past
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. double legacyMoney = double.Parse(Console.ReadLine());
  14. int lastYear = int.Parse(Console.ReadLine());
  15.  
  16. int livingYears = lastYear - 1800;
  17.  
  18. var difference = legacyMoney;
  19.  
  20. for (int firstYear = 0; firstYear <= livingYears; firstYear++)
  21. {
  22. if (firstYear % 2 == 0) // Triabva da napravia proverka za chetna i nechetna data
  23. {
  24. difference -= 12000;
  25. }
  26.  
  27. else
  28. {
  29. difference -= (12000 + (50* (18 + firstYear)));
  30. }
  31. }
  32.  
  33.  
  34. if (difference >= 0)
  35. {
  36. Console.WriteLine("Yes! He will live a carefree life and will have {0:f2} dollars left.", Math.Abs(difference));
  37. }
  38.  
  39. else
  40. {
  41. Console.WriteLine("He will need {0:f2} dollars to survive.", Math.Abs(difference));
  42. }
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment