From 1c47181d1cdf9aa1aabe0c2769dc71fd524c3e16 Mon Sep 17 00:00:00 2001 From: "ali.hh.ramadhan@gmail.com" Date: Wed, 24 Mar 2021 21:24:52 -0400 Subject: [PATCH] Flesh out Compound interest problem --- .../templates/problems/compound-interest.html | 26 ++++++++++++------- .../templates/problems/plump-moose.html | 2 +- src/static/code_stubs/c/compound_interest.c | 4 +++ src/static/code_stubs/c/plump_moose.c | 4 +++ .../javascript/compound_interest.js | 4 +++ .../code_stubs/julia/compound_interest.jl | 4 +++ .../code_stubs/python/compound_interest.py | 4 +++ src/static/visualization/compound-interest.js | 14 ++++++++-- 8 files changed, 49 insertions(+), 13 deletions(-) diff --git a/src/problems/templates/problems/compound-interest.html b/src/problems/templates/problems/compound-interest.html index dca02b0..1c31411 100644 --- a/src/problems/templates/problems/compound-interest.html +++ b/src/problems/templates/problems/compound-interest.html @@ -3,7 +3,7 @@ {% load static %} {% block you_will_learn %} - cold moose are plump. + the most powerful force in the world according to Einstein. [citation needed] {% endblock %} {% block problem_body %} @@ -15,28 +15,31 @@

If you start with an amount of money $m$ and the compound interest is calculated once a year with interest rate $r$ - (as a fraction) then after $n$ years you end up with new amount $M$ given by + (as a fraction between 0 and 1) then after $n$ years you end up with a new amount $M$ given by $$ M = m (1 + r)^n $$


+This plot shows the growth of $m = 1,000$ dollars compounded every year at 10% ($r = 0.1$) for $n = 25$ years. +

- Submit some code with a function compound_interest(m, r, n) that computes $M$ given $m$, $r$, and $n$. + Submit some code with a function compound_interest(m, r, n) that computes the final amount $M$ after + starting with an amount $m$ compounded yearly at a rate $r$ for $n$ years.

{% endblock %} {% block input_description %} -m, r, n +Starting amount $m$, rate $r$, and number of years $n$. {% endblock %} {% block output_description %} -M +Final amount $M$. {% endblock %} {% block examples %} @@ -45,8 +48,8 @@

Example

Input: $1,000, 0.07, 25 -Output: $5,427.43
+ style="font-family: monospace; text-align: justify; word-wrap: break-word; white-space:pre;">Input: 1000, 0.07, 25 +Output: 5427.43 {% endblock %} @@ -59,11 +62,14 @@

Notes