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, 22.06.2019 10:40
Nims is applicable to all stakeholders with incident related responsibilities. true or false
Answers: 1
question
Computers and Technology, 22.06.2019 14:00
Which database model is best used for data warehouse and data mining
Answers: 3
question
Computers and Technology, 22.06.2019 18:00
Which of the following physical laws can make the flow of water seem more realistic? a. motion b. gravity c. fluid dynamics d. thermodynamics
Answers: 2
question
Computers and Technology, 22.06.2019 22:20
Avariable of the data type arrays is storing 10 quantities. what is true about these quantities? a. the quantities all have different characteristics. b. the quantities all have the same characteristics. c. five quantities have the same and five have different characteristics. d. it is necessary for all quantities to be integers. e. it is necessary for all quantities to be characters.
Answers: 2
You know the right answer?
Extend by inheritance the BankAccount Class to create two new subclasses: SavingsAccount
Che...
Questions
question
Mathematics, 25.06.2021 14:00
question
Mathematics, 25.06.2021 14:00
question
English, 25.06.2021 14:00
Questions on the website: 13722367