visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
294 experts, 1172 registered users, 1625 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


The DDRK link is back online.
We got a one week service interruption, sorry.
(23-30/01/2010)

Algorithms :: Maths :: Compound Interest....


By: progGoon U.S.A.  Date: 05/01/2003 00:00:00  English  Points: 75 Status: Answered
Quality : Excellent
Would someone please help me & write a program that asks the user to input his initial amount of money and the interest rate at which it is invested. The interest is compounded annually. The program should output the interest earned each year and the compounded principle until the money has doubled. It should output on the screen:

Year Principle Interest
1
2
.
.
Your money has doubled after - years.

-Thankyou...
By: monange Date: 05/01/2003 03:26:00 English  Type : Comment
We can't do your homework for you. If you actually write something, then run into a problem you can't solve, we can help you then.
By: VGR Date: 05/01/2003 05:29:00 English  Type : Answer
okay, in Pascal then.

Program compute (InPut, OutPut);

Var interestrate : Real; // plat-form dependent, but who cares
capital : double; // could be "comp"
i : Byte; // number of years to compute

const numyears = 12; // put whatever you want

Begin
Write('Please input the original amount ');
ReadLn(capital); // no type-checking
WriteLn;
Write('Please input the yearly interest rate ');
ReadLn(interestrate); // no type-checking
WriteLn;
For i:=1 to numyears Do
Begin
WriteLn('Year ',i,' amount=',amount,' interest=',(amount*interestrate):10:3); // a formatted output using TABs or some fixed length using value:m:f - see example - could be better
amount:=amount*(1+interestrate);
End; // For
WriteLn('Done.');
End. // compute Program


PS i'm minimizing memory consumption, not the number of operations, please introduce extra variables, like an array, if you would like to "keep memory" of intermediary results, or ask the user for the numyears variable's value, etc etc
By: VGR Date: 05/01/2003 05:30:00 English  Type : Comment
above, all "amount" variable references should read "capital", sorry. Wrote this too fast

Do register to be able to answer

 Add This Article To:
 del.icio.usDel.icio.us  diggDigg  googleGoogle  spurlSpurl
 blinkBlink  wongWong  simpySimpy  yahooY! MyWeb 
EContact
browser fav
page generated in 62.224150 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page