Question: I am practicing on making a loan repayment program for java for homework. ( past question i am stuck on ) It will have 4

I am practicing on making a loan repayment program for java for homework. (past question i am stuck on)
It will have 4 main classes and attributes to them.
CLASS=SavingsAccount/ ATTRIBUTES = interestRate, balance/ BEHAVIOUR = getBalance, addInterest, makeDeposit.
CLASS = CurrentAccount/ ATTRIBUTES = interestRate, balance/ BEHAVIOUR = getBalance, addInterest, makeDeposit.
CLASS = LoanAccount/ ATTRIBUTES = interestRate, balance/ BEHAVIOUR = getBalance, addInterest, makePayment.
CLASS= PensionAccount/ ATTRIBUTES = interestRate, withdrawalAmount/BEHAVIOUR = getBalance, addInterest, makePayment.
The names of the attributes and behaviour should make obvious to you what their function should be. I will give a short explanation for each:
interestRate- The monthly interest rate of each account. This should be a class variable (example, not an instance variable) and also private to the class. In other words, any change to this attribute should reflect on all the instances of the class it belongs to. This attribute should be initialised for each class as follows: The interestRate for SavingsAccount should be initialised to 0.008(i.e.0.8%). The interestRate for CurrentAccount should be initialised to 0.0006(i.e.0.06%). The interestRate for LoanAccount should be initialised to 0.012(i.e.1.2%). The interestRate for PensionAccount should be initialised to 0.025(i.e.2.5%).
getBalance -This method should take no arguments and return the balance. It is required because balance will not be accessible directly.
addInterest- This method should compute and add the interest to the account using its interest rate. It takes no arguments and returns nothing.
makeDeposit- This method should take the amount to be deposited to the account as an argument and add that to the balance.
makePayment- This method should take the amount to be paid into the loan account and subtract that from the balance. For pension account, the amount needs to be added to the withdrawalAmount.
Each of the four classes should also have constructor methods. You are expected to use two constructors for each of the classes SavingsAccount, CurrentAccount and PensionAccount: one that takes no arguments and initialises the balance to 0.0 and another that takes and uses a starting balance for the account to be created. There should only be one constructor method for the LoanAccount class that should take and use a starting balance (example, the amount borrowed when the account is created).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!