Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Bank account (6 Points) Implement a class BankAccount in package com.labs.lab2 that models a bank account. For a bank account you should store the balance,

image text in transcribedimage text in transcribed

Bank account (6 Points) Implement a class BankAccount in package com.labs.lab2 that models a bank account. For a bank account you should store the balance, the owner's name, whether this is a checking or saving account, and the overdraw limit which is the maximum amount the account can fal below zero, e.g., if the overdraw limit is 30.0 then the account balance is not allowed to drop below -30.0 . When the balance is set, then make sure that it is greater than or equal to-withdrawal limit It should be possible to withdraw money from an account using a method double withDraw(double amount) that you have to implement. This method has to check whether the there is sufficient balance such that after the withdrawal the account balance is still above the overdraw limit. In case the withdrawal would cause the balance to drop below the limit, no money should be withdrawn. The return value of the method is the amount of money that was withdrawn. Do not forget to update the balance if the withdrawal is successful. If the account is a savings account then the bank charges a 3 dollar fee for each withdrawal. Note that the fee has to be taken into account when calculating the new account balance and when checking the overdraft limit .Similarly, it should be possible to deposit money into the account using a method void deposit(double amount) This increases balance by amount . It should also be possible to transfer money from one account to another. That should be imple- mented as a method boolean transfer (BankAccount to, double amount) . This method transfers amount from the bank account on which this method is called to bank account to. If this would cause the balance of the source account to drop below the overdraft limit, then the transfer should be abandoned (no balances are changed). The method returns true if the transfer is successful and false otherwise. Interest calculation (3 Points) Create a class InterestCalculator in package com.labs.lab2 which has a single static method double applyInterest (BankAccount a, int years, double interestRate) which applies interestRate percent interest to the balance of bank account a for years years and returns the final balance of a after the interest has been applied. Recall that for x% interest the account balance is updated like this: balance balance (1 100 Write a main method that tests applyInterest using the following test case: Create a saving bank account for Alice with $110 balance. . Apply 5% interest for 8 years and print the final account balance

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What are the role of supervisors ?

Answered: 1 week ago

Question

What advice would you provide to Jennifer?

Answered: 1 week ago

Question

What are the issues of concern for each of the affected parties?

Answered: 1 week ago