subject

Extend by inheritance the BankAccount Class to create two new subclasses: SavingsAccount
CheckingAccount
DO NOT CODE ANY METHODS IN THE SUBCLASSES OTHER THAN THE CONSTRUCTOR. ALL THE METHODS SHOULD COME FROM THE PARENT CLASS AUTOMATICALLY BY INHERITANCE.

CODING METHODS (OTHER THAN THE CONSTRUCTOR) IN THE SUBCLASSES WILL VOID YOUR LAB FROM ANY CREDIT.

Your BankAccount is the parent class.

Be sure to ADD to your BankAccount class the static method transfer(BankAccount origin, BankAccount destination) from Exam 2.
If you did not code this method in your exam 2, I will post one in this week's discussion.

In main(), use the file accounts-1.txt create an array of BankAccount, CheckingAccount and SavingsAccount objects.

This can be done using the following fragment in main():

// create the arrays of the 3 types of accounts
BankAccount[] accounts = new BankAccount[fileSize];
SavingAccount[] savingsAccounts = new SavingsAccount[fileSize];
CheckingAccount[] checkingAccounts = new CheckingAccount[fileSize];

// Use a loop to call the constructors
for(int i=0 ; i 0)
{
System. out. println("The account was located in record "+ location);
System. out. println(accounts[location]);
System. out. println("Checking:\n " + checkingAccounts[location]);
System. out. println("Savings:\n "+ savingsAccounts[location]);
}
else
{
System. out. println("No account with id " +id + " was located");
}
Now, if you run the sample code from above, and the accounts were properly constructed, we expect the following result:

Please enter the account ID: 55922
The account was located in record 950
Account #: 55922
Owner: Doyle May
Balance: $4,355.59

Checking:
Account #: 55922
Owner: Doyle May
Balance: $2,177.80

Savings:
Account #: 55922
Owner: Doyle May
Balance: $2,177.80

The last step for this Lab is to use the static method from Exam 2

BankAccount. transfer(BankAccount origin, BankAccount destiny)
to transfer all the money from the savings account to the checking account. Using the same account from the example above, we can code the transfer in main() like follows:

BankAccount. transfer( savingsAccounts[location], checkingAccounts[location] );

System. out. println(accounts[location]);
System. out. println("Checking after transfer:\n " + checkingAccounts[location]);
System. out. println("Savings after transfer:\n "+ savingsAccounts[location]);
The output if the method is properly working should be:

Account #: 55922
Owner: Doyle May
Balance: $4,355.59

Checking after transfer:
Account #: 55922
Owner: Doyle May
Balance: $4,355.59

Savings after transfer:
Account #: 55922
Owner: Doyle May
Balance: $0.00
As you can see, the balances were updated by the transfer method.

SUBMIT THREE (3) files: The file with your main() method, the subclasses SavingsAccount. java and CheckingAccount. java

(The files needed for the code are attached the BankAccount java is suppose to the super class while, the accounts-1 text file is what you have to incorporate with it)

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 03:00
What are the different parts of computer
Answers: 2
question
Computers and Technology, 23.06.2019 06:30
To become an audio technician, the most successful tactics might include the following. (select all that apply). learning how to persuade other people gaining different types of experience in audio technology learning as much as possible about art history establishing a reputation as a reliable professional
Answers: 1
question
Computers and Technology, 23.06.2019 12:00
Using the list, you can select the number of photos that will appear on each slide. a. theme b. frame shape c. pictures in album d. picture layout
Answers: 1
question
Computers and Technology, 23.06.2019 13:00
Which one of the following voltages should never be measured directly with a vom? a. 1200 v b. 500 v c. 800 v d. 100v
Answers: 2
You know the right answer?
Extend by inheritance the BankAccount Class to create two new subclasses: SavingsAccount
Che...
Questions
Questions on the website: 13722363