subject

File Account. java (see previous exercise) contains a definition for a simple bank account class with methods to withdraw, deposit, get the balance and account number, and return a String representation. Note that the constructor for this class creates a random account number. Save this class to your directory and study it to see how it works. Then write the following additional code: 1. Suppose the bank wants to keep track of how many accounts exist. Declare a private static integer variable numAccounts to hold this value. Like all instance and static variables, it will be initialized (to 0, since it's an int) automatically a. e every time an account is created. b. Add code to the constructor to increment this variabl c. Add a static method getNumAccounts that returns the total number of accounts. Think about why this method should be static its information is not related to any particular account. File TestAccountsI java contains a simple program that creates the specified number of bank accounts then uses the getNumAccounts method to find how many accounts were created. Save it to your directory, then use it to test your modified Account class. d. 2. Add a method void close0 to your Account class. This method should close the current account by appending CLOSED" to the account name and setting the balance to 0. (The account number should remain unchanged.) Also decrement the total number of accounts. 3. Add a static method Account consolidate(Account accti, Account acct2) to your Account class that creates a new account whose balance is the sum of the balances in acctl and acct2 and closes acctl and acct2. The new account should be returned. Two important rules of consolidation: Only accounts with the same name can be consolidated. The new account gets the name on the old accounts but a new account number. Two accounts with the same number cannot be consolidated. Otherwise this would be an easy way to double your money Check these conditions before creating the new account. If either condition fails, do not create the new account or close the old ones, print a message and return null. 4. Write a test program that prompts for and reads in three names and creates an account with an initial balance of S 100 for each. Print the three accounts, then close the first account and try to consolidate the second and third into a new account. Now print the accounts again, including the consolidated one if it was created.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 17:00
Match the following. 1. show grouping of word processing tasks that can be performed quick access toolbar 2. shortcut location for commonly used elements scroll bars 3. organized commands used to modify documents ribbon 4. used to align and measure content in a word screen zoom bar 5. vertical and horizontal bars that are used to navigate through a document contextual tabs 6. displays the name of the document in use ruler 7. allows users to enlarge or shrink a visual of a word document title bar
Answers: 2
question
Computers and Technology, 23.06.2019 22:00
Jackson, who works in the finance department of a company, is holding a seminar for other employees on how to file taxes. only three employees sign up to attend the seminar. which device can he use to share his presentation with a group of three employees?
Answers: 1
question
Computers and Technology, 24.06.2019 06:30
Adrawing that places all lines parallel to the z axis at an angle from the horizon is 99 ! a. an oblique drawing b. a perspective drawing c. an auxiliary view d. a one-point perspective drawing
Answers: 2
question
Computers and Technology, 24.06.2019 10:00
When writing a business letter, how many times can you use the same merge field in a document? once once, unless using the address block feature unlimited it will depend on the type of document you choose
Answers: 1
You know the right answer?
File Account. java (see previous exercise) contains a definition for a simple bank account class wit...
Questions
question
Mathematics, 11.07.2019 07:10
question
Mathematics, 11.07.2019 07:10
question
English, 11.07.2019 07:10
Questions on the website: 13722363