Question
*Note* plz i need this code in java Q 2: Consider following hierarchy of classes: (5*4) Implement this hierarchy in Java while fulfilling following conditions
*Note* plz i need this code in java Q 2: Consider following hierarchy of classes: (5*4) Implement this hierarchy in Java while fulfilling following conditions : i. Class BankAccount is abstract with two abstract methods credit() and debit() ii. 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.
|
| Bank Account |
| ||
|
| -accountNumber :double -accountBalance :don. |
| ||
|
| +credit(double): //abstract +debt(double): //abstract |
| ||
|
|
|
| ||
SavingAccount CurrentAccont -yearlyprofit: double -yearlyTaxRate:double +credit(double): //concrete +credit(double): //concrete +debt(double): //concrete +d.t(dOtIble): //concrete | |||||
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