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