| RHS => Allan => Basic Programming => Exercises => BankAccount |
Updated:
02/02/2004 23:36 WebMaster: allanhn@rhs.dk |
BankAccount
The Problem
A bank is offering a special account
with a special high interest rate per year..
Once the account is made it is not possible
to deposit or withdraw money to/from the account.
The account exists for 5 years - then the customer has to withdraw the
total amount.
You are to develop a computer program handling the calculation of interest and balance for such an account.
Question 1
Before you start programming the solution discuss in your study group the following
questions:
Input: Which data must be read in;
i.e. entered by the user?
Declarations: Which classes, data fields
and types are needed for the program?
Calculations: Which data must be calculated and how?
Output: Which data must be printed out and how?
The answers to these questions are to be written down on paper. This will give you a pretty good idea on how the program should be structured.
Question 2
You are to create a program, which can handle such a bank account.
You will
need a class BankAccount, and a BankAccountApp with the usual main method.
Then, in main, do the usual readings, read in start balance and interest
in percent (%) and then call a method in BankAccount which in table form
print
out: term
number, primo balance, interest and ultimo balance for each term.
Write the program, compile, run it with the following input:
| Start balance | Interest in % | ||
| 1000 | 10.0 |
The oputput should look something like:
| Term number | Primo | Interest | Ultimo | ||
| 1 | 1000 | 100 | 1100 | ||
| 2 | 1100 | 110 | 1210 | ||
| 3 | 1210 | 121 | 1331 | ||
| 4 | 1331 | 133.1 | 1464.1 | ||
| 5 | 1464.1 | 146.41 | 1610.51 |
Question 3
Change the program so it also reads in a tax percentage
and instead print out in table form: term number, primo balance, interest,
netto interest and ultimo balance for each term (netto interest is interst
minus tax).
Question 4 Optional
Change the program so it stops not after a specific number of terms but when
the balance exceeds twice the start balance!