Question: In this question, you are to (1) augment the Account class by adding some new data fields and modifying some existing methods; and (2) modify

 In this question, you are to (1) augment the Account class

by adding some new data fields and modifying some existing methods; and

(2) modify the main method of the AccountTest class. Add the following

two data fields to the Account class: - A private data field

In this question, you are to (1) augment the Account class by adding some new data fields and modifying some existing methods; and (2) modify the main method of the AccountTest class. Add the following two data fields to the Account class: - A private data field named accountNumber of type int, representing the account number that uniquely identifies an account. Add the getter for the data field - A private static data field named numAccounts of type int, representing the number of account objects that have been created of the Account class. Add the getter for the data field. Modify the following methods already in the Account class: - In the constructors, in addition to the initialization of balance, increment the static numAccounts data field by one and then assign the result to the accountNumber field. - Have the method public String toString( ) return a string of the form (Account Number: accountNumber, Balance: balance) where accountNumber is the value of the accountNumber field and balance is the value of the balance field. Keep two decimal places for the balance. In the Account class, write a static method public static double averageBalance (ArrayList accounts) that takes a list of accounts as input and returns the average balance of all accounts in the input list. In the main( ) method of the Account Test class: - Create an Account object named account1 using the default constructor. Print object to the console. If your default constructor and the toString( ) method are correct, your code should print (Account Number: 1, Balance: 0.00) - Create an Array List named accounts. - Create a Random object named random, using 2150 as the seed. - Write a loop to create 5 Account objects and add them to the accounts list. For the construction of each Account object, generate a random number between 0 and 1,000,000 for its initial balance. - Print the accounts list to the console. If your constructor and the toString() method are correct, your code should print [(Account Number: 2, Balance: 905651.38), (Account Number: 3, Balance: 628963.69), (Account Number: 4, Balance: 557445.55), (Account Number: 5, Balance: 104361.90), (Account Number: 6, Balance: 686829.89)] - Use the static method getNumAccounts( ) of the Account class to read the number of accounts created, and print the result to the console. Your code should print 6 accounts. - Invoke the static method averageBalance of the Account class to compute the average balance of all accounts in the accounts list created above. Print the result to the console, keeping two decimal places. Your code should print Average Balance: 576650.48 AccountTest.java

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!