Answer to Question #336700 in Java | JSP | JSF for bel

Question #336700

Create your own class named BankAccount that illustrates the use of encapsulation as shown above.

Make sure to include at least one setter and one getter for the class. Add variables and methods

related to a BankAccount class as many as you can.


1
Expert's answer
2022-05-04T17:39:48-0400
public class BankAccount {
    private int IdNumber;
    private int balance;
    private int bonuses;
    private String ownerName;

    private int generateID(int idNumber) {
        idNumber = (int) ( Math.random() * 5000 ) + 1000;
        return idNumber;
    }

    public void info(String ownerName, int balance) {
        System.out.println("Name of owner - " + ownerName);
        System.out.println("Balance: " + balance);
    }

    public int accrualBonuses(int bonuses) {
        bonuses = bonuses + (balance % 10) / 2;
        return bonuses;
    }

    public int getBalance() {
        return balance;
    }

    public void setBalance(int balance) {
        this.balance = balance;
    }

    public int getBonuses() {
        return bonuses;
    }

    public void setBonuses(int bonuses) {
        this.bonuses = bonuses;
    }

    public String getOwnerName() {
        return ownerName;
    }

    public void setOwnerName(String ownerName) {
        this.ownerName = ownerName;
    }
}

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