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.