desislava777

Back to the past

Nov 4th, 2017
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 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 ConsoleApplication83
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. var x = double.Parse(Console.ReadLine());
  14. var godina = int.Parse(Console.ReadLine());
  15. int age = 18;
  16. for (int i = 1800; i<= godina; i++)
  17. {
  18. if (i % 2 == 0)
  19. {
  20. x-=12000;
  21. }
  22. else
  23. {
  24. x=x - (12000 + age * 50);
  25. }
  26. age++;
  27. }
  28. if (x>=0)
  29. {
  30. Console.WriteLine("Yes! He will live a carefree life and will have {0:0.00} dollars left.", x);
  31. }
  32. else if (x<0)
  33. {
  34. Console.WriteLine("He will need {0:0.00} dollars to survive.", Math.Abs(x));
  35. }
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment