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