Untitled
unknown
plain_text
a year ago
663 B
5
Indexable
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."); }
Editor is loading...
Leave a Comment