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

Create a class named BankAccount with attributes to hold the account number, the

ID: 3672933 • Letter: C

Question

Create a class named BankAccount with attributes to hold the account number, the owner’s name, and the account balance. Create gets and sets for these three attributes. Also create a method named deductMonthlyFee that deducts a monthly fee from the account balance. The monthly fee is $4.00. Create a method named addDeposit that has one variable passed into it. This method updates the account balance by adding the value passed to the class’ account balance. Create a method named deductCheck that has one variable passed into it. This method update the account balance by subtracting the value passed from the class’ account balance. Create another method that prints out all of the class’ attributes.

Explanation / Answer


class BankAccount
{
   int acc_no;
   double acc_bal;
   String own_nm;

   void set(int a,double ab,String n)
   {
       acc_no=a;
       acc_bal=ab;
       own_nm=n;
   }

   void deductMonthlyFee()
   {
       acc_bal=acc_bal-4.0;
   }

   void addDeposit (double amt)
   {
       acc_bal=acc_bal+amt;
   }

   void deductCheck (double amt)
   {
       acc_bal=acc_bal-amt;
   }

   void print()
   {
       System.out.println("Account Owners Name="+own_nm);
       System.out.println("Account Number="+acc_no);
       System.out.println("Account Balance="+acc_bal);
   }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote