Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Back_To_The_Past
- {
- class Program
- {
- static void Main(string[] args)
- {
- double moneyInherited = double.Parse(Console.ReadLine());
- int yearToSurvive = int.Parse(Console.ReadLine());
- int startYear = 1800;
- int yearsToLive = yearToSurvive - startYear;
- int yearsOfAge = 18;
- for(int i = 0;i<=yearsToLive;i++)
- {
- if (startYear % 2 == 0)
- {
- moneyInherited = moneyInherited - 12000;
- startYear++;
- yearsOfAge++;
- }
- else if (startYear % 2 != 0)
- {
- moneyInherited = moneyInherited - (12000 + 50 * yearsOfAge);
- startYear++;
- yearsOfAge++;
- }
- }
- if(moneyInherited>=0)
- {
- Console.WriteLine($"Yes! He will live a carefree life and will have {moneyInherited:f2} dollars left.");
- }
- else
- {
- moneyInherited = Math.Abs(moneyInherited);
- Console.WriteLine($"He will need {moneyInherited:f2} dollars to survive.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment