Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Q2: Consider following hierarchy of classes: (5*4) Bank Account -account Number double -accountBalance double +credit(double): //abstract +debt(double): //abstract 4 SavingAccount -yearlyprofit: double CurrentAccont -yearly TaxRate:double
Q2: Consider following hierarchy of classes: (5*4) Bank Account -account Number double -accountBalance double +credit(double): //abstract +debt(double): //abstract 4 SavingAccount -yearlyprofit: double CurrentAccont -yearly TaxRate:double +credit(double): //concrete +debt(double): I/concrete + credit(double): //concrete +debt(double): //concrete ii. Implement this hierarchy in Java while fulfilling following conditions: 1. Class"" BankAccount" is abstract with two abstract methods credit() and debit() Write appropriate parameterized constructors for all 3 classes in the above hierarchy (keeping in mind the concept of constructors while using Inheritance). iii. a. Implement Abstract function credit(double) in class "SavingAccount" so that input parameter amount of type "double" gets added to the "accountBalance" b. Implement Abstract function debit(double) in class "SavingAccount" so that input parameter amount of type "double" gets subtracted from the "accountBalance" c. Implement Abstract function credit(double) in class "CurrentAccount" so that input parameter amount of type "double" gets added to the "accountBalance" while deducting 0.6% tax on each transaction d. Implement Abstract function debit(double) in class "CurrentAccount" so that input parameter amount of type "double" gets added to the "accountBalance while deducting 0.6% tax on each transaction While implementing a debit() operation always perform a check that account balance is available or not. iv. In the main function create an 5-member array of type "BankAccount". Point each member of this array to either SavingAccount or CurrentAccount class objects. All 5 objects must be different to each other. Then call credit() and debit() for each index of the above created array using a loop on array
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started