Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace BackToThePast
- {
- class Program
- {
- static void Main(string[] args)
- {
- //input money inherited and last year
- //ivancho age = 18
- //ivancho startyear = 1800 / 18 years old
- //if year % 2 == 0 ivancho spends 12000
- //else if year % 2 == ivancho spends 12000 + 50 * ivancho age
- //sum money spend for the years
- //will the money be enough
- //output
- double moneyInherited = double.Parse(Console.ReadLine());
- int lastYear = int.Parse(Console.ReadLine());
- int ivanchoAge = 18;
- double moneySpend = 0;
- for (int i = 1800; i <= lastYear; i++)
- {
- if (i % 2 == 0)
- {
- moneySpend += 12000;
- }
- else if (i % 2 == 1)
- {
- moneySpend += 12000 + 50 * ivanchoAge;
- }
- ivanchoAge += 1;
- }
- if (moneyInherited >= moneySpend)
- {
- Console.WriteLine($"Yes! He will live a carefree life and will have {moneyInherited - moneySpend:f2} dollars left.");
- }
- else
- {
- Console.WriteLine($"He will need {moneySpend - moneyInherited:f2} dollars to survive.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement