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

please tell me how to write the last method Help + /* This class models a user\'

ID: 3756861 • Letter: P

Question

please tell me how to write the last method

Help + /* This class models a user's account. The class keeps track of the user's current balance, number of items purchased, and the total monetary amount purchased. TODO: implement all of the methods in this class definition. public class UserAccount f string userName; double balance; int numPurchases; double totalPurchaseAmt; constructor that initializes this account with a user name and an initial balance that is passed in. It also initializes the number of purchases made to e, and the total monetary amount of all purchases to e 9 public UserAccount (String userName, double initBal) f e int numPurchases e; 1 double totalPurchaseAmt e.e; 4 4 * Returns the user's name. 6 public String getUserName() f return userName; .8 29 /* Returns the user's balance. 1/ 32 public double getBalance() ( return balance; 34 35 36 37 38 39 40 41 /* Returns the number of purchases made. public int getNumPurchases() ( return numPurchases; ccountManagjavrccountjava UserAccount Testjava Compile Messages GRASP Messages Run /O Interactions UserAccount.java UserAccountTest.java End at UserAccountTest.orderBookBalanceCorrectAfterNoPurchaseTest(UserAccount at Java . base/jdk. nternal. reflect . NativeMethodAccessorImpl.invokee(Native at java.base/jdk. nternal.reflect.NativeMethodAccessor Impl.invoke (NativeM Clear

Explanation / Answer

public boolean makePurchase(double itemPrice)

{

if(itemPrice<=balance)

{

numPurchases= numPurchases+1;

totalPurchaseAmt=itemPrice+totalPurchaseAmt;

balance=balance-itemPrice;

return true;

  

}

else

{

return false;

}

}