Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Suppose that you are provided with a pre-written class BankAccount as shown below. (The headings are shown, but not the method bodies, to save space.)

image text in transcribed

Suppose that you are provided with a pre-written class BankAccount as shown below. (The headings are shown, but not the method bodies, to save space.) Assume that the fields, constructor, and methods shown are already implemented. You may refer to them or use them in solving this problem if necessary. Write an instance method named transactionFee that will be placed inside the BankAccount class to become a part of each BankAccount object's behavior. The transactionFee method accepts a fee amount (a real number) as a parameter, and applies that fee to the user's past transactions. The fee is applied once for the first transaction, twice for the second transaction, three times for the third, and so on. These fees are subtracted out from the user's overall balance. If the user's balance is large enough to afford all of the fees with greater than $0.00 remaining, the method returns true. If the balance cannot afford all of the fees or has no money left, the balance is left as 0.0 and the method returns false //A BankAccount keeps track of a user's money balance and ID, // and counts how many transactions (deposits/withdrawals) are made. public class BankAccount private String id; private double balance; private int transactions; /7 Constructs a BankAccount object with the given id, and // e balance and transactions. public BankAccount (String id) /I returns the field values public double getBalance() public String getID) public String getTransactions () //Adds the amount to the balance if it is between 0-500 //Also counts as 1 transaction public void deposit(double amount) // Subtracts the amount from the balance if the user has enough money Also counts as 1 transaction public void withdraw(double amount) / your method would go here

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions

Question

Her response see the attached memo is disturbing.

Answered: 1 week ago