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 _4.BackToThePast
- {
- class Program
- {
- static void Main(string[] args)
- {
- double heritage = double.Parse(Console.ReadLine());
- int yearToLive = int.Parse(Console.ReadLine());
- double yearsold = 17;
- for (int year = 1800; year <= yearToLive; year++)
- {
- if (year % 2 == 0)
- {
- heritage = heritage - 12000;
- }
- else if(year % 2 != 0)
- {
- yearsold += 2;
- heritage = heritage - (12000 + (50 * yearsold));
- }
- }
- if (heritage >= 0)
- {
- Console.WriteLine("Yes! He will live a carefree life and will have {0:F2} dollars left.", heritage);
- }
- else
- {
- Console.WriteLine("He will need {0:F2} dollars to survive.", Math.Abs(heritage));
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment