Parent Directory
|
Revision Log
Revision 145 - (view) (download)
| 1 : | jj | 145 | ##DESCRIPTION |
| 2 : | ## compound interest | ||
| 3 : | ##ENDDESCRIPTION | ||
| 4 : | |||
| 5 : | ##KEYWORDS('compound interest') | ||
| 6 : | |||
| 7 : | # | ||
| 8 : | # First comes some stuff that appears at the beginning of every problem | ||
| 9 : | # | ||
| 10 : | |||
| 11 : | DOCUMENT(); # This should be the first executable line in the problem. | ||
| 12 : | |||
| 13 : | loadMacros( | ||
| 14 : | "PG.pl", | ||
| 15 : | "PGbasicmacros.pl", | ||
| 16 : | "PGchoicemacros.pl", | ||
| 17 : | "PGanswermacros.pl", | ||
| 18 : | "PGauxiliaryFunctions.pl", | ||
| 19 : | "PGgraphmacros.pl" | ||
| 20 : | ); | ||
| 21 : | |||
| 22 : | TEXT(beginproblem()); | ||
| 23 : | |||
| 24 : | #make compound period and n arrays | ||
| 25 : | @compounding = ("daily","weekly","monthly","quarterly","semi-annually"); | ||
| 26 : | @compoundingn = (365, 52, 12, 4, 2); | ||
| 27 : | |||
| 28 : | #pick a compounding period | ||
| 29 : | $a=random(0,4); | ||
| 30 : | |||
| 31 : | #pick a starting amount | ||
| 32 : | $amount = random (50000,200000,10000); | ||
| 33 : | |||
| 34 : | #pick an interest rate | ||
| 35 : | $rate = random(5,12,.5); | ||
| 36 : | |||
| 37 : | #change rate to a decimal | ||
| 38 : | $r=$rate/100; | ||
| 39 : | |||
| 40 : | #determine the answers | ||
| 41 : | $ans1 = $amount /((1 + ($r /$compoundingn[$a]))**($compoundingn[$a]*1)); | ||
| 42 : | $ans10 = $amount /((1 + ($r /$compoundingn[$a]))**($compoundingn[$a]*10)); | ||
| 43 : | $ans20 = $amount /((1 + ($r /$compoundingn[$a]))**($compoundingn[$a]*20)); | ||
| 44 : | $ans30 = $amount /((1 + ($r /$compoundingn[$a]))**($compoundingn[$a]*30)); | ||
| 45 : | $ans40 = $amount /((1 + ($r /$compoundingn[$a]))**($compoundingn[$a]*40)); | ||
| 46 : | $ans50 = $amount /((1 + ($r /$compoundingn[$a]))**($compoundingn[$a]*50)); | ||
| 47 : | |||
| 48 : | BEGIN_TEXT | ||
| 49 : | Complete the table below giving the amount \(P\) that must be invested at interest rate $rate $PERCENT | ||
| 50 : | compounded $compounding[$a] to obtain a balance of \(A\) = $DOLLAR$amount in \(t\) years. | ||
| 51 : | |||
| 52 : | $PAR | ||
| 53 : | $BCENTER | ||
| 54 : | \{begintable(2)\} | ||
| 55 : | \{ row("\(t\)","\(P\)") \} | ||
| 56 : | \{ row("1",ans_rule(20)) \} | ||
| 57 : | \{ row("10",ans_rule(20)) \} | ||
| 58 : | \{ row("20",ans_rule(20)) \} | ||
| 59 : | \{ row("30",ans_rule(20)) \} | ||
| 60 : | \{ row("40",ans_rule(20)) \} | ||
| 61 : | \{ row("50",ans_rule(20)) \} | ||
| 62 : | \{endtable()\} | ||
| 63 : | $ECENTER | ||
| 64 : | END_TEXT | ||
| 65 : | |||
| 66 : | |||
| 67 : | ANS(num_cmp($ans1)); | ||
| 68 : | ANS(num_cmp($ans10)); | ||
| 69 : | ANS(num_cmp($ans20)); | ||
| 70 : | ANS(num_cmp($ans30)); | ||
| 71 : | ANS(num_cmp($ans40)); | ||
| 72 : | ANS(num_cmp($ans50)); | ||
| 73 : | |||
| 74 : | ENDDOCUMENT(); # This should be the last executable line in the problem. |
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |