Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. In the Account class, write a method called transferTo , which transfers mone

ID: 3613390 • Letter: 1

Question

1. In theAccount class, write a method calledtransferTo, which transfers money between 2

accounts. Themethod takes 2 parameters. The 1st parameter is the amount of moneythat

needs to betransferred, and the 2nd parameter is a reference to theAccount that will receive

the money. Theaccount from which the money is withdrawn from (i.e. the accountthat is

giving themoney) is the Account object that is performingthe method.

YourtransferTo method must use (call) thewithdraw and deposit method.

Your methodmust work according to the following description and method header(you must

copy this intoyour Account class):

/**transfer money (amount dollars) from this account to thereceiver account;

   * if amount < 0 then nothinghappens;

   * if the sending account does not have enoughmoney (this includes the amount to send

     and the transactionfee),then no money will be transferred and no transaction fee  

    will be charge;

   * /

publicvoid transferTo(double amount, Account receiver)

{

           //WRITE YOUR CODE HERE

}

2. Then, inthe AccountTester class, make sure your methodworks according to the comment.

Here is asimple example of using the transferTo method, butyou will need to do more

testing to besure that the method is working properly:

//Atthe start, Adam has $500 and Betty has $0

Account a1 = new account(“Adam”);

Account a2 = new account(“Betty”);

//Nowtransfer $100 from Adam to Betty

A1.transferTo(100,a2)

//Adamshould have $398.5 (transaction fee $1.5),

//andBetty should have $100

System.out.println(a1.getOwner() + “ has$” a1.getBalance());

System.out.println(a2.getOwner() + “ has$” a2.getBalance());

Explanation / Answer

please rate - thanks note: I changed getName to getOwner Account /* This class represents a bank account * @author: */ class Account { // Instance Variables // Money in the bank account, in dollars private double balance; // Full name of the person who owns the account private String owner; private int id; private static final double fee=1.5; private static double rate=.01; private static int numberofaccounts=0; // Constructor /** * Creates a new Account belonging to 'name' */ public Account(String name) { owner = name; balance = 0; id=++numberofaccounts; } // Instance Methods /** * Add 'amount' dollars into the account * If amount < 0, then nothing happens */ public void deposit(double amount) { if (balance >= 0) balance = balance + amount; } /** * Deduct 'amount' dollars from the account * If amount < 0, then nothing happens * If there is not enough money in the account, then nothinghappens */ public void withdraw(double amount) { if(amount