Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

Students also viewed these Databases questions

Question

3. What is ethnocentric bias?

Answered: 1 week ago

Question

13-4 What are alternative methods for building information systems?

Answered: 1 week ago