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