Algorithms :: Maths :: Compound Interest.... |
|||
| By: progGoon |
Date: 05/01/2003 00:00:00 |
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 | 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 | 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 | 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: | |||
| |
|
|
|
| |
|
|
|








