Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- class Program
- {
- static void Main()
- {
- decimal inheritance = decimal.Parse(Console.ReadLine());
- int endYear = int.Parse(Console.ReadLine());
- decimal expences = 0m;
- decimal remainingSum = 0m;
- int yearsIvan = 18;
- for (int i = 1800; i <= endYear; i++)
- {
- if (i%2==0)
- {
- if (i>1800)
- {
- inheritance = remainingSum;
- }
- expences = 12000;
- remainingSum = inheritance - expences;
- }
- else
- {
- expences = 12000 + yearsIvan * 50;
- remainingSum = remainingSum - expences;
- }
- yearsIvan++;
- }//end of for
- if (remainingSum>=0)
- {
- Console.WriteLine($"Yes! He will live a carefree life and will have {remainingSum:f2} dollars left.");
- }
- else
- {
- Console.WriteLine($"He will need {-remainingSum:f2} dollars to survive.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment