官术网_书友最值得收藏!

  • Scala Programming Projects
  • Mikael Valot Nicolas Jorand
  • 96字
  • 2021-07-23 16:25:20

Implementing simulatePlan

The implementation for simulatePlan is straightforward; we call futureCapital twice with different arguments:

def simulatePlan(interestRate: Double,
nbOfMonthsSaving: Int, nbOfMonthsInRetirement: Int,
netIncome: Int, currentExpenses: Int, initialCapital:
Double) : (Double, Double) = {
val capitalAtRetirement = futureCapital(
interestRate = interestRate, nbOfMonths = nbOfMonthsSaving,
netIncome = netIncome, currentExpenses = currentExpenses,
initialCapital = initialCapital)

val capitalAfterDeath = futureCapital(
interestRate = interestRate, nbOfMonths = nbOfMonthsInRetirement,
netIncome = 0, currentExpenses = currentExpenses,
initialCapital = capitalAtRetirement)

(capitalAtRetirement, capitalAfterDeath)
}

Run RetCalcSpec again, and it should pass now. Feel free to experiment calling simulatePlan from the Scala Console with different values.

主站蜘蛛池模板: 萍乡市| 曲靖市| 杨浦区| 海原县| 如皋市| 潍坊市| 绥宁县| 榕江县| 松滋市| 星座| 谷城县| 当涂县| 寻甸| 柏乡县| 邵东县| 班玛县| 乐安县| 天水市| 仙桃市| 兴仁县| 塔河县| 盈江县| 饶平县| 宝清县| 巴彦淖尔市| 东丰县| 和龙市| 白山市| 阜新市| 西乌| 广州市| 临颍县| 双峰县| 女性| 高唐县| 临安市| 双柏县| 嵩明县| 建德市| 衡阳县| 五河县|