Untitled

mail@pastecode.io avatar
unknown
plain_text
25 days ago
663 B
2
Indexable
Never
double receivedMoney = double.Parse(Console.ReadLine());

int yearHeNeedsToLive = int.Parse(Console.ReadLine());

//Calculations 

double leftMoney = receivedMoney;

int ageCounter = 18;

for (int year = 1800; year <= yearHeNeedsToLive; year++)
{
    if (year % 2 == 0)
    {
        leftMoney -= 12_000;
    }
    else
    {
        leftMoney -= 12_000 + 50 * ageCounter;
    }

    

    ageCounter++;
}


if (leftMoney >= 0)
{
    Console.WriteLine($"Yes! He will live a carefree life and will have {leftMoney:f2} dollars left.");
}
else
{
    Console.WriteLine($"He will need {Math.Abs(leftMoney):f2} dollars to survive.");
}
Leave a Comment