Answer to Question #192365 in Java | JSP | JSF for King

Question #192365

8. Develop a program by designing a class to represent a bank account. Include the 

  following members:

Data Members:

Name of the Depositor

Account Number

Type of account

Balance

Methods:

getdetails( )   ---To assign initial values

deposit( )  ---To deposit an amount

withdraw( ) ---To withdraw an amount after checking balance

display( )--- To display the name and balance.



1
Expert's answer
2021-05-14T11:09:10-0400
public class BankAccount {
    private String nameOfDepositor;
    private int accountNumber;
    private String typeOfAccount;
    private double balance;

    public void getDetails(String nameOfDepositor, int accountNumber, String typeOfAccount, double balance) {
        this.nameOfDepositor = nameOfDepositor;
        this.accountNumber = accountNumber;
        this.typeOfAccount = typeOfAccount;
        this.balance = balance;
    }

    public void deposit(double amount) {
        balance += amount;
    }

    public void withdraw(double amount) {
        if (balance >= amount) {
            balance -= amount;
        }
    }

    public void display() {
        System.out.println(nameOfDepositor + " Balance: " + balance);
    }

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS