In this lab, you will be creating new classes that are derived from a class called...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
In this lab, you will be creating new classes that are derived from a class called BankAccount. A checking account is a bank account and a savings account is a bank account as well. This sets up a relationship called inheritance, where BankAccount is the superclass and CheckingAccountand Savings Account are subclasses. This relationship allows CheckingAccount to inherit attributes from BankAccount (like owner, balance, and account Number, but it can have new attributes that are specific to a checking account, like a fee for clearing a check. It also allows CheckingAccount to inherit Page 1 of 4 methods from BankAccount, like deposit, that are universal for all bank accounts. You will write a withdraw method in CheckingAccount that overrides the withdraw method in BankAccount, in order to do something slightly different than the original withdraw method. You will use an instance variable called account Number in SavingsAccount to hide the account Number variable inherited from BankAccount. The UML diagram for the inheritance relationship is as follows: BankAccount - balance: double - owner: String - accountNumber : String # numberOfAccounts: int methods from BankAccount, like deposit, that are universal for all bank accounts. You will write a withdraw method in CheckingAccount that overrides the withdraw method in BankAccount, in order to do something slightly different than the original withdraw method. You will use an instance variable called account Number in SavingsAccount to hide the accountNumber variable inherited from BankAccount. The UML diagram for the inheritance relationship is as follows: - FEE: double - balance: double - owner: String - accountNumber : String #numberOfAccounts: int BankAccount + BankAccount(): + BankAccount(name: String, amount : double): + BankAccount(old Account : BankAccount, amount : double): + deposit (amount : double): void + withdraw(amount: double): boolean CheckingAccount + getBalance(): double + getOwner(): String + getAccount Number (): String + setBalance (amount: double): void + setAccountNumber(newAccount Number : String): void + CheckingAccount(name: String, amount : double): + withdraw (amount : double): boolean SavingsAccount - rate : double - savingsNumber: int - accountNumber : String + SavingsAccount(name: String, amount : double): + SavingsAccount(oldAccount : Savings Account, amount:double): + postinterest ():void + getAccount Number (): String Task #1 Extending the BankAccount Class (6 pts) 1. Copy the files AccountDriver.java and BankAccount.java as directed by your instructor. BankAccount.java is complete and will not need to be modified. 2. Create a new class called CheckingAccount that extends BankAccount. 3. It should contain a static constant FEE that represents the cost of clearing one check. Set it equal to 15 cents. 4. Write a constructor that takes a name and an initial amount as parameters. It should call the constructor for the superclass. It should initialize account Number to be the current value in account Number concatenated with -10 (all checking accounts at this bank are identified by the extension -10). There can be only one checking account for each account number. Remember since account Number is a private member in BankAccount, it must be changed through a mutator method. 5. Write a new instance method, withdraw, that overrides the withdraw method in the superclass. This method should take the amount to withdraw, add to it the fee for check clearing, and call the withdraw method from the superclass. Remember that to override the method, it must have the same method heading. Notice that the withdraw method from the superclass returns true or false depending on if it was able to complete the withdrawal or not. The method that overrides it must also return the same true or false that was returned from the call to the withdraw method from the superclass. 6. Compile and debug this class. Task #2 Creating a Second Subclass (6 pts) 1. Create a new cla BankAccount. Savings Account that extends 2. It should contain an instance variable called rate that represents the annual interest rate. Set it equal to 2.5%. 3. It should also have an instance variable called savings Number, initialized to 0. In this bank, you have one account number, but can have several savings accounts with that same number. Each individual savings account is identified by the number following a dash. For example, 100001-0 is the first savings account you open, 100001-1 would be another savings account that is still part of your same account. This is so that you can keep some funds separate from the others, like a Christmas club account. 4. An instance variable called accountNumber, that will hide the account Numberfrom the superclass, should also be in this class. 7. Write a constructor that takes a name and an initial balance as parameters and calls the constructor for the superclass. It should initialize account Number to be the current value in the superclass account Number (the hidden instance variable) concatenated with a hyphen and then the savingsNumber. 5. Write a method called postInterest that has no parameters and returns no value. This method will calculate one month's worth of interest on the balance and deposit it into the account. 6. Write a method that overrides the getAccount Number method in the superclass. 8. Write a copy constructor that creates another savings account for the same person. It should take the original savings account and an initial balance as parameters. It should call the copy constructor of the superclass, and assign the savingsNumber to be one more than the savings Number of the original savings account. It should assign the account Number to be the account Number of the superclass concatenated with the hyphen and the savingsNumber of the new account. 9. Compile and debug this class. 10. Use the AccountDriver class to test out your classes. If you named and created your classes and methods correctly, it should not have any difficulties. If you have errors, do not edit the Account Driver class. You must make your classes work with this program. 11. Running the program should give the following output: Account Number 100001-10 belonging to Benjamin Franklin Initial balance = $1000.00 After deposit of $500.00, balance = $1500.00 After withdrawal of $1000.00, balance = $499.85 Account Number 100002-0 belonging to William Shakespeare Initial balance = $400.00 After deposit of $500.00, balance = $900.00 Insufficient funds to withdraw $1000.00, balance = $900.00 After monthly interest has been posted, balance $901.88 Account Number 100002-1 belonging to William Shakespeare Initial balance = $5.00 After deposit of $500.00, balance = $505.00 Insufficient funds to withdraw $1000.00, balance = $505.00 Account Number 100003-10 belonging to Isaac Newton In this lab, you will be creating new classes that are derived from a class called BankAccount. A checking account is a bank account and a savings account is a bank account as well. This sets up a relationship called inheritance, where BankAccount is the superclass and CheckingAccountand Savings Account are subclasses. This relationship allows CheckingAccount to inherit attributes from BankAccount (like owner, balance, and account Number, but it can have new attributes that are specific to a checking account, like a fee for clearing a check. It also allows CheckingAccount to inherit Page 1 of 4 methods from BankAccount, like deposit, that are universal for all bank accounts. You will write a withdraw method in CheckingAccount that overrides the withdraw method in BankAccount, in order to do something slightly different than the original withdraw method. You will use an instance variable called account Number in SavingsAccount to hide the account Number variable inherited from BankAccount. The UML diagram for the inheritance relationship is as follows: BankAccount - balance: double - owner: String - accountNumber : String # numberOfAccounts: int methods from BankAccount, like deposit, that are universal for all bank accounts. You will write a withdraw method in CheckingAccount that overrides the withdraw method in BankAccount, in order to do something slightly different than the original withdraw method. You will use an instance variable called account Number in SavingsAccount to hide the accountNumber variable inherited from BankAccount. The UML diagram for the inheritance relationship is as follows: - FEE: double - balance: double - owner: String - accountNumber : String #numberOfAccounts: int BankAccount + BankAccount(): + BankAccount(name: String, amount : double): + BankAccount(old Account : BankAccount, amount : double): + deposit (amount : double): void + withdraw(amount: double): boolean CheckingAccount + getBalance(): double + getOwner(): String + getAccount Number (): String + setBalance (amount: double): void + setAccountNumber(newAccount Number : String): void + CheckingAccount(name: String, amount : double): + withdraw (amount : double): boolean SavingsAccount - rate : double - savingsNumber: int - accountNumber : String + SavingsAccount(name: String, amount : double): + SavingsAccount(oldAccount : Savings Account, amount:double): + postinterest ():void + getAccount Number (): String Task #1 Extending the BankAccount Class (6 pts) 1. Copy the files AccountDriver.java and BankAccount.java as directed by your instructor. BankAccount.java is complete and will not need to be modified. 2. Create a new class called CheckingAccount that extends BankAccount. 3. It should contain a static constant FEE that represents the cost of clearing one check. Set it equal to 15 cents. 4. Write a constructor that takes a name and an initial amount as parameters. It should call the constructor for the superclass. It should initialize account Number to be the current value in account Number concatenated with -10 (all checking accounts at this bank are identified by the extension -10). There can be only one checking account for each account number. Remember since account Number is a private member in BankAccount, it must be changed through a mutator method. 5. Write a new instance method, withdraw, that overrides the withdraw method in the superclass. This method should take the amount to withdraw, add to it the fee for check clearing, and call the withdraw method from the superclass. Remember that to override the method, it must have the same method heading. Notice that the withdraw method from the superclass returns true or false depending on if it was able to complete the withdrawal or not. The method that overrides it must also return the same true or false that was returned from the call to the withdraw method from the superclass. 6. Compile and debug this class. Task #2 Creating a Second Subclass (6 pts) 1. Create a new cla BankAccount. Savings Account that extends 2. It should contain an instance variable called rate that represents the annual interest rate. Set it equal to 2.5%. 3. It should also have an instance variable called savings Number, initialized to 0. In this bank, you have one account number, but can have several savings accounts with that same number. Each individual savings account is identified by the number following a dash. For example, 100001-0 is the first savings account you open, 100001-1 would be another savings account that is still part of your same account. This is so that you can keep some funds separate from the others, like a Christmas club account. 4. An instance variable called accountNumber, that will hide the account Numberfrom the superclass, should also be in this class. 7. Write a constructor that takes a name and an initial balance as parameters and calls the constructor for the superclass. It should initialize account Number to be the current value in the superclass account Number (the hidden instance variable) concatenated with a hyphen and then the savingsNumber. 5. Write a method called postInterest that has no parameters and returns no value. This method will calculate one month's worth of interest on the balance and deposit it into the account. 6. Write a method that overrides the getAccount Number method in the superclass. 8. Write a copy constructor that creates another savings account for the same person. It should take the original savings account and an initial balance as parameters. It should call the copy constructor of the superclass, and assign the savingsNumber to be one more than the savings Number of the original savings account. It should assign the account Number to be the account Number of the superclass concatenated with the hyphen and the savingsNumber of the new account. 9. Compile and debug this class. 10. Use the AccountDriver class to test out your classes. If you named and created your classes and methods correctly, it should not have any difficulties. If you have errors, do not edit the Account Driver class. You must make your classes work with this program. 11. Running the program should give the following output: Account Number 100001-10 belonging to Benjamin Franklin Initial balance = $1000.00 After deposit of $500.00, balance = $1500.00 After withdrawal of $1000.00, balance = $499.85 Account Number 100002-0 belonging to William Shakespeare Initial balance = $400.00 After deposit of $500.00, balance = $900.00 Insufficient funds to withdraw $1000.00, balance = $900.00 After monthly interest has been posted, balance $901.88 Account Number 100002-1 belonging to William Shakespeare Initial balance = $5.00 After deposit of $500.00, balance = $505.00 Insufficient funds to withdraw $1000.00, balance = $505.00 Account Number 100003-10 belonging to Isaac Newton
Expert Answer:
Answer rating: 100% (QA)
Comments and output attached public class AccountDriver public static void mainString args double putin 500 double takeout 1000 String money String moneyin String moneyout boolean completed Test the C... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Macheso was employed on a three-year contract as an administration manager for Magocha Plc. Machesos employment contract for the three years only provided for an annual salary of P650,000 and an...
-
For each polynomial function, find (a) (-1), (b) (2), and (c) (0). f(x)=x5x4
-
Which assumed inventory cost flow method: (a) Usually parallels the actual physical flow of merchandise? (b) Divides cost of goods available for sale by total units available for sale to determine a...
-
At high temperatures, a dynamic equilibrium exists between carbon monoxide, carbon dioxide, and solid carbon. At 900oC, Kc is 0.238. a. What is the value of Kp? b. Some carbon dioxide is added to the...
-
One design challenge for a capacitor-powered electric car is that the voltage would change with time as the capacitors discharged. If the capacitors in a car were discharged to half their initial...
-
Analysis of Various Accounting Changes and Errors Katherine Irving, controller of Lotan Corp., is aware that a pronouncement on accounting changes has been issued. After reading the pronouncement,...
-
Nour's responsibilities include creating organizational goals and overall strategy for the organization. In terms of her level in the organization, what type of manager is Nour?
-
Recall a time when you were involved in a group similar to the Bayside City Tire Companya time when a decision had to be made. What were some of the rules that influenced the process of decision...
-
The company Enerficil Ltda is dedicated to the sale of industrial batteries. The company sold the previous year 478,400 units and expects to sell 33.3% more this year, the minimum time of delay...
-
Consider a relation R with five attributes ABCDE. You are given the following dependencies: A B, BC E, and ED A. 1. List all keys for R. 2. Is R in 3NF? 3. Is R in BCNF? -
-
What are the uses of recombinant DNA pharmaceuticals?
-
Employer Summary: Kelly is the senior finance manager for Achieve Financial Services and has been tasked with hiring a new financial analyst for their growing international portfolio. Many...
-
A systems analysis is required when: An agency wishes to purchase multiple expense items and the aggregate cost exceeds the expense/investment threshold. A unit intends to purchase multiple...
-
Please solve: log (base 4) (x^2 - 3) + log (base 4) 10 = 1
-
Question 1- The sales Funnel and the negotiation process The sales funnel is an extremely useful tool in order t classify customers, specially for B2B purposes. We already know that we can use it to...
-
In Problem use absolute value on a graphing calculator to find the area between the curve and the x axis over the given interval. Find answers to two decimal places. y = x 3 ln x; 0.1 x 3.1
-
You are a financial accountant with the Town of Willow Creek, preparing for the upcoming year end of December 31, 2013. Required (a) The balance recorded for the closure and post-closure liability...
-
Two real estate companies jointly buy the land and buildings that constitute a shopping centre. The companies separately nanced their share of the shopping centre acquisition. They set up a separate...
-
When Hydra Ltd. acquired the shares of Draco Ltd., one of the assets in Dracos statement of nancial position was $15,000 goodwill , which had been recognized by Draco upon its acquisition of a...
-
What is a reliable customer?
-
Briefly describe what is meant by an organization that has customer focus.
-
What role does customer satisfaction play in the development of reliable customers?
Study smarter with the SolutionInn App