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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 03:00, Julianhooks
State 7 common key's for every keyboard
Answers: 1
image
Computers and Technology, 23.06.2019 13:00, torresnoemi899
Which of the following statements is false? a. a class can directly inherit from class object. b. if the class you're inheriting from declares instance variables as private, the inherited class can access those instance variables directly. c. a class's instance variables are normally declared private to enforce good software engineering. d. it's often much more efficient to create a class by inheriting from a similar class than to create the class by writing every line of code the new class requires.
Answers: 3
image
Computers and Technology, 23.06.2019 22:20, tagerryawilson6
If i uninstall nba 2k 19 from my ps4 will my career be gone forever?
Answers: 2
image
Computers and Technology, 23.06.2019 23:30, jamalchris9353
Worth 50 points answer them bc i am not sure if i am wrong
Answers: 1
You know the right answer?
Extend by inheritance the BankAccount Class to create two new subclasses: SavingsAccount
Che...

Questions in other subjects: