Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need answer for this in Vb.net Problem: Create an inheritance hierarchy that a bank might use to represent customer bank accounts. All customers at this

Need answer for this in Vb.net

Problem: Create an inheritance hierarchy that a bank might use to represent customer bank accounts. All customers at this bank can deposit (that is, credit) money into their accounts and withdraw (that is, debit) money from their accounts. More specific types of accounts also exist. Savings accounts, for instance, earn interest on the money they hold. Checking accounts, on the other hand, dont earn interest and charge a fee per transaction. Create base class Account and derived classes SavingsAccount and CheckingAccount that inherit from class Account. Base class Account should include a Private instance variable of type Decimal to represent the account balance. The class should provide a constructor that receives an initial balance and uses it to initialize the instance variable with a Public property. The property should validate the initial balance to ensure that its greater than or equal to 0.0. If not, the balance should be set to 0.0, and the Set accessor should throw an exception, indicating that the initial balance was invalid. The class should provide two Public methods. Method Credit should add an amount to the current balance. Method Debit should withdraw money from the Account and ensure that the debit amount does not exceed the Accounts balance. If it does, the balance should be left unchanged, and the method should throw an exception indicating that the debit amount exceeded the account balance. The class should also provide a Get accessor in property Balance that returns the current balance. Derived class SavingsAccount should inherit the functionality of an Account, but also include a Double instance variable indicating the interest rate (percentage) assigned to the Account. Class SavingsAccounts constructor should receive the initial balance, as well as an initial value for the interest rate. SavingsAccount should provide Public method CalculateInterest that returns a Decimal indicating the amount of interest earned by an account. Method CalculateInterest should determine this amount by multiplying the interest rate by the account balance. [Note: SavingsAccount should inherit methods Credit and Debit without redefining them.] Derived class CheckingAccount should inherit from base class Account and include a Decimal instance variable that represents the fee charged per transaction. CheckingAccounts constructor should receive the initial balance, as well as a parameter indicating a fee amount.

Class Checking-Account should redefine methods Credit and Debit so that they subtract the fee from the account balance whenever either transaction is performed successfully. CheckingAccounts versions of these methods should invoke the base-class Account version to perform the updates to an account balance. CheckingAccounts Debit method should charge a fee only if money is actually withdrawn (that is, the debit amount does not exceed the account balance).

After defining the classes in this hierarchy, write an app that creates objects of each class and tests their methods. Add interest to the SavingsAccount object by first invoking its Calculate- Interest method, then passing the returned interest amount to the objects Credit method.

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

Step: 3

blur-text-image

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

Database And Expert Systems Applications 31st International Conference Dexa 2020 Bratislava Slovakia September 14 17 2020 Proceedings Part 1 Lncs 12391

Authors: Sven Hartmann ,Josef Kung ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

303059002X, 978-3030590024

More Books

Students also viewed these Databases questions

Question

which case set the original standard for expert testimony

Answered: 1 week ago