If you have tried to call simulatePlan from the Scala Console, you probably tried different values for nbOfMonths and observed the resulting capital at retirement and after death. It would be useful to have a function that finds the optimal nbOfMonths so that you have enough capital to never run out of money during your retirement.
Calculating when you can retire
Writing a failing test for nbOfMonthsSaving
As usual, let's start with a new unit test to clarify what we expect from this function:
"RetCalc.nbOfMonthsSaving" should {
"calculate how long I need to save before I can retire" in {
val actual = RetCalc.nbOfMonthsSaving(
interestRate = 0.04 / 12, nbOfMonthsInRetirement = 40 * 12...