The following class describes an Account. public class Accou…
The following class describes an Account. public class Account { private int accountId, accountBalance; public Account(int id, int balance) { accountId=id; accountBalance=balance; } public boolean transferMoney(Account otherAccount, int transferAmount) { /*postcondition: * if otherAccount has at least transferAmount * the transfer to the current Account is made and * true is returned * otherwise * the transfer is not made and * false is returned */ //missing code } public String toString() { return accountId+” has balance $”+accountBalance; } //other methods not shown } An Account object has an accountId and an accountBalance. The method transferMoney takes as parameters: the Account object otherAccount. transferAmount, the amount of money to transfer from otherAccount to the current Account. When this method is completed, it will do the following: if otherAccount has at least transferAmount the transfer to the current Account is made and true is returned otherwise the transfer is not made and false is returned For example, if the following code segment appears in a client program: Account a1=new Account(13567,5000); Account a2=new Account(24567,2000); System.out.println(“Starting balances:”); System.out.println(a1); System.out.println(a2); System.out.println(); System.out.println(“1. Try to transfer $1000 from 24567 to 13567”); if (a1.transferMoney(a2,1000)==true) System.out.println(“Successful transfer”); else System.out.println(“Unsuccessful transfer”); System.out.println(a1); System.out.println(a2); System.out.println(); System.out.println(“2. Try to transfer $1100 from 24567 to 13567”); if (a1.transferMoney(a2,1100)==true) System.out.println(“Successful transfer”); else System.out.println(“Unsuccessful transfer”); System.out.println(a1); System.out.println(a2); The output should be: Starting balances: 13567 has balance $5000 24567 has balance $2000 1. Try to transfer $1000 from 24567 to 13567 Successful transfer 13567 has balance $6000 24567 has balance $1000 2. Try to transfer $1100 from 24567 to 13567 Unsuccessful transfer 13567 has balance $6000 24567 has balance $1000 Which of the following code segments should replace //missing code so that transferMoney works as intended? A if (this.transferAmount>otherAccount.accountBalance) return false; this.accountBalance+=this.transferAmount; otherAccount.accountBalance-=this.transferAmount; return true; B if (transferAmount>this.accountBalance) return false; this.accountBalance+=transferAmount; otherAccount.accountBalance-=transferAmount; return true; C if (transferAmount>otherAccount.accountBalance) return false; this.accountBalance+=transferAmount; otherAccount.accountBalance-=transferAmount; return true; D if (transferAmount>otherAccount.accountBalance) return false; this.accountBalance+=transferAmount; otherAccount.accountBalance-=transferAmount;