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

Computer Organization and Programming (JAVA) Assigned date: 3/20 Due Date: 4/3 C

ID: 3739660 • Letter: C

Question

Computer Organization and Programming (JAVA)

Assigned date: 3/20 Due Date: 4/3 Concepts: Classes and objects, relationships between objects, array of objects Point value: 100 points Note: Use the Java Class, Account.java, provided. Please do not rename or make any changes to this class. Do not turn in the Account class. Your program will be tested with my own copy of the Account class provided (which is the same as yours) 1. Write a Java class, XXXX_Bank, where XXXX where XXXX is your Kean email id. (5 points) 2. At the beginning of the program, include a comment with your name and a brief description of the program. Please include a short comment before each method (5 points) 3. The Bank class will have the following instance variables: 5 points) a. An Array of Account objects that can hold 20 Accounts named, accounts b. An int variable, numberOfAccounts which indicates the number of Account objects in the account array 2. The Bank class will have the following constructor: a. A default/noargs constructor: (5 points) i. It will create the Array of Account objects ii. Set the numberOfAccounts to zero b. One accessor method: (5 points) public int getNumberOfAccountsO //returns the numberOfAccounts C. The following methods public void addAccount (Account a) (5 points) .Adds Account a to the Array of accounts Adds 1 to the numberOfAccounts public void addAccount(double initBalance) (5 points) Creates a new Account using initBalance Adds the new Account to the Array of accounts Adds 1 to the numberOfAccounts

Explanation / Answer

/**

* File: ABCBank.java

* Created 2018/03/29

* Author Sathya

* Version 1.0

*/

public class ABCBank {

Account account[];

int numberOfAccounts;

/*

* Default Constructor

* To create array for account and to set numberOfAccounts as 0

*/

ABCBank(){

account = new Account[20];

numberOfAccounts = 0;

}

/*

* Returns the numberOfAccounts

*/

public int getNumberOfAccounts(){

return numberOfAccounts;

}

/*

* To add new account to account list

* a represents account object

* Addition of a to account list and numberOfAccounts

*/

public void addAccount(Account a){

account[numberOfAccounts] = a;

numberOfAccounts++;

}

/*

* To add new account created using initBalance to account list  

*/

public void addAccount(double initBalance){

Account b = new Account(initBalance);

account[numberOfAccounts] = b;

numberOfAccounts++;

}

/*

* To add maximnum balance

* max variable for maximum value

*/

public void addAccount(double initBalance){

int max = 0;

for(Object acc : account){

if(acc.getBalance() > max)

max = acc.getBalance();

}

System.out.println("Maximum Balance is : "+max);

}

/*

* To get Total Balance of all acounts

* total variable for total balance

*/

public void getTotalBalance(){

int total = 0;

for(Object acc : account){

total = total + acc.getBalance();

}

System.out.println("Total Balance is : "+total);

}

/*

* Returns String representation of ABCBank

* @see java.lang.Object#toString()

*/

public String toString(){

ABCBank abc = new ABCBank();

return abc.toString();

}

}

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