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 heritage = double.Parse(Console.ReadLine());
- int yearToLiveTo = int.Parse(Console.ReadLine());
- int currAge = 18;
- double moneySpent = 0.0;
- for (int currYear = 1800; currYear <= yearToLiveTo; currYear++)
- {
- if (currYear % 2 == 0)
- {
- //12 000
- moneySpent += 12000;
- }
- else if (currYear % 2 == 1)
- {
- //12 000 + (50 * currAge)
- moneySpent += 12000 + (50 * currAge);
- }
- currAge++;
- }
- if (heritage >= moneySpent)
- {
- Console.WriteLine($"Yes! He will live a carefree life and will have {(heritage - moneySpent):f2} dollars left.");
- }
- else
- {
- Console.WriteLine($"He will need {(moneySpent - heritage):f2} dollars to survive.");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment