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 BackToThePast
- {
- class BackToThePast
- {
- static void Main(string[] args)
- {
- double money = double.Parse(Console.ReadLine());
- double year = double.Parse(Console.ReadLine());
- double moneyForSpend = 0.0;
- double age= 19.0;
- for (int i = 1800; i <= year; i++)
- {
- if (i % 2 == 0)
- moneyForSpend += 12000;
- else
- {
- moneyForSpend += 12000 + 50 * age;
- age+= 2;
- }
- }
- if (money >= moneyForSpend)
- {
- double n = money - moneyForSpend;
- Console.WriteLine($"Yes! He will live a carefree life and will have {n:F2} dollars left.");
- }
- else
- {
- double m = moneyForSpend - money;
- Console.WriteLine($"He will need {m:F2} dollars to survive.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment