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

A) Describe what this class represents and what it does: B) What methods make up

ID: 3903391 • Letter: A

Question

A) Describe what this class represents and what it does:

B) What methods make up the class’s public interface?

public class MyClass

{

   private String firstName;

   private String lastName;

   private int idNumber;

   private double balance;

public MyClass()

   {

     this.firstName = "";

     this.lastName = "";

     this.idNumber = -1;

     this.balance = 0.0;

   }

public MyClass(String firstName, String lastName, int id)

   {

     this.firstName = firstName;

     this.lastName = lastName;

     this.idNumber = id;

     this.balance = 0.0;

   }

public void makeDeposit(int id, double amount)

   {

     if(this.confirm(id))

     {

        this.balance += amount;

     }

   }

public void withdraw(int id, double amount)

   {

     if(this.confirm(id))

     {

        if(amount > this.balance)

           System.out.println("Not enough in account");

        else

           this.balance -= amount;

     }

   }

private boolean confirm(int id)

   {

     if(this.idNumber == id)

        return true;

     else

     {       

        System.out.println("INVALID");

        return false;

     }

   }

}

A) Describe what this class represents and what it does:

B) What methods make up the class’s public interface?

Explanation / Answer

Q(A)
This class represents a banking account with the member variables - Account holder's first and last name, Account number and the balance amount in the account.
The class supports different methods to manage the account - create a new account (constructor), make a deposit or withdraw amount and also confirm if an account id exists

Q(B) - Public methods

1. Creating a new accounts
public MyClass()
public MyClass(String firstName, String lastName, int id)


2. Make a deposit for the given account id and amount
public void makeDeposit(int id, double amount)

3. Withdraw amount from account
public void withdraw(int id, double amount)Q(A)
This class represents a banking account with the member variables - Account holder's first and last name, Account number and the balance amount in the account.
The class supports different methods to manage the account - create a new account (constructor), make a deposit or withdraw amount and also confirm if an account id exists

Q(B) - Public methods

1. Creating a new accounts
public MyClass()
public MyClass(String firstName, String lastName, int id)


2. Make a deposit for the given account id and amount
public void makeDeposit(int id, double amount)

3. Withdraw amount from account
public void withdraw(int id, double amount)

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