Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

d. File TestAccounts1.java contains a simple program that creates the specified number of bank accounts then uses the getNumAccounts method to find how many accounts

image text in transcribed
d. File TestAccounts1.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 dass. 2. Add a method void close() 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 acct1, Account acct2) to your Account dass that creates a new account whose balance is the sum of the balances in acct1 and acct2 and doses acct 1 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 useful 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 $ 100 for each. Print the three accounts, then dose the first account and try to consolidate the second and third into a new account. Now print the accounts again, induding the consolidated one if it was created. // TestAccounts1 // A simple program to test the numAccts method of the // Account class. import java . util . Scanner; public class TestAccounts1 public static void main (String args) Account testAcct; Scanner scan = new Scanner ( System. in) ; System. out . println ( "How many accounts would you like to create?") ; int num = scan . nextInt() ; for (int i=l; i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions

Question

What are the important Land forms in Lithosphere ?

Answered: 1 week ago

Question

What Is The Responsibility Of A Pharmacist?

Answered: 1 week ago

Question

Q.1. what is constitution? Q.2. key of the constitution?

Answered: 1 week ago