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

create your own class Account that represents a bank account. Your Account class

ID: 3632962 • Letter: C

Question

create your own class Account that represents a bank account. Your Account class should have:
name the name of the owner
accNo the acct number
balance the current balance

a constructor that takes a String and a double and initializes name and balance with these. The constructor also gives an acct no which is an increasing unique number. for example: the first acct number created gets an acct no = 1, the second = 2, third = 3 etc, etc.
the class Account should also have the following methods:
public void deposit (double amount) that adds amount to the balance
public void withdrawal (double amount) that subtracts amount from the balance
public double getBalance() that returns the current balance
public int getNumber() that returns the account number
a toString* method that returns a string representation of the account

toString method is:
public String toString(){
return "Account "+"for""+ name+"has$"+balance;
}

next create another class called Bank that represents bank and in which we will keep a number of accounts in an array of type Account[]
your class Bank should have:
one instance variable called theAccts of type Account[] and another instance variable numOfAccts (of type int) which will contain at any moment the number of accounts in the array theAccts.
a default constructor that initializes theAccts to an array of size 100 and numOfAccts to 0 and another constructor which takes an int parameter n representing the size of the array theAccts. when called this constructor initializes the array theAccts to size n and numOfAccts to 0.
methods:
public void addAcct (account x) adds account x to the bank
public double totalBalance() returns the sum of all balances of all accounts in the bank
public void addInterest (double percent) adds an interest to each and every account
public void printCustomers() prints for each account the name, accNo and balance.

Explanation / Answer

//So here my implementation //I have three classes one for the Account, Bank, and main method //I also have a demo that I set up in the main method //Hope this is what you were asking for, it was kinda fun, cheers. public class Account { private String name; private int acctNum=0; private double balance; public Account(String n, double b, int aNum) { name = n; balance = b; acctNum = aNum; } public void deposit(double amount) { balance += amount; } public void withdrawal(double amount) { balance -= amount; } public double getBalance() { return balance; } public int getNumber() { return acctNum; } public String toString() { return "Account for " + name + " has account number " + acctNum + " and a balance of $" + balance + "."; } } ////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////// public class Bank { private Account []theAccts; private int numOfAccts; public Bank() { theAccts = new Account[100]; numOfAccts = 0; } public Bank(int n) { theAccts = new Account[n]; numOfAccts = 0; } public void addAcct(Account x) { theAccts[numOfAccts] = x; numOfAccts++; } public double totalBalance() { double sum = 0; for (int i = 0; i