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 04:00
Acetylene is a gas which burns rapidly on its own, and is considered highly explosive. a) true b) false
Answers: 2
question
Computers and Technology, 22.06.2019 17:30
Working on this program in python 3.7: a year in the modern gregorian calendar consists of 365 days. in reality, the earth takes longer to rotate around the sun. to account for the difference in time, every 4 years, a leap year takes place. a leap year is when a year has 366 days: an extra day, february 29th. the requirements for a given year to be a leap year are: 1) the year must be divisible by 42) if the year is a century year (1700, 1800, the year must be evenly divisible by 400some example leap years are 1600, 1712, and 2016.write a program that takes in a year and determines whether that year is a leap year.ex: if the input is 1712, the output is: 1712 is a leap year. ex: if the input is 1913, the output is: 1913 is not a leap year. your program must define and call the function isleapyear(useryear). the function should return true if the input year is a leap year and false otherwise.
Answers: 1
question
Computers and Technology, 22.06.2019 17:40
Consider the simple 3-station assembly line illustrated below, where the 2 machines at station 1 are parallel, i.e., the product only needs to go through one of the 2 machines before proceeding to station 2.what is the throughput time of this process?
Answers: 2
question
Computers and Technology, 23.06.2019 07:10
If you want to import a picture into a dtp application, what must you do first? draw an image frame. import text. open the folder containing the file. select get image… from the windows menu.
Answers: 2
You know the right answer?
File Account. java (see previous exercise) contains a definition for a simple bank account class wit...
Questions
question
Mathematics, 27.02.2021 02:00
question
Mathematics, 27.02.2021 02:00
question
Mathematics, 27.02.2021 02:00
question
Mathematics, 27.02.2021 02:00
question
Mathematics, 27.02.2021 02:00
question
Biology, 27.02.2021 02:00
question
Mathematics, 27.02.2021 02:00
question
Mathematics, 27.02.2021 02:00
Questions on the website: 13722361