Question: Do this Code in JavaOpp. Q2: Consider following hierarchy of classes: (5*4) Bank Account -account Number double -accountBalance double +credit(double): abstract +det(double): //abstract SavingAccount -yearlyprofit
Q2: Consider following hierarchy of classes: (5*4) Bank Account -account Number double -accountBalance double +credit(double): abstract +det(double): //abstract SavingAccount -yearlyprofit double +credit(double): concrete debt(double): concrete CurrentAccont -yearly TaxRate:double +Credit(double): concrete +det(double): Aconcrete i. ii Implement this hierarchy in Java while fulfilling following conditions: 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). 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 "account Balance" 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 "Current Account so that input parameter amount of type "double" gets added to the "accountBalance" while deducting 0.6% tax on each transaction iv. While implementing a debit() operation always perform a check that account balance is available or not. In the main function create an 5-member array of type "BankAccount". Point each member of this array to either SavingAccount or Current Account 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
Get step-by-step solutions from verified subject matter experts
