Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Recall that we have designed a simple Account class to represent a bank account in the previous lab. Now Create an inheritance hierarchy that a
Recall that we have designed a simple Account class to represent a bank account in the previous lab. Now Create an inheritance hierarchy that a bank might use to represent customers' bank accounts. All customers at this bank can deposit (i.e., credit) money into their accounts and withdraw (i.e., 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, charge a fee per transaction The BaseAccount class contains the following: a protected data field named id for the account. . a protected data field named balance for the account. two overloaded constructors. You should validate the initial balance to ensure that it is greater than or equal to o.0. Some public methods: getld). getBalance) . A toString() method that returns the ld and balance of an account. . A deposit) method that adds an amount to the current balance. A withdraw) method that withdraws money from the account and ensure that the amount does not exceed the Account's balance. If it does, the balance should be left unchanged, and the method should print the message "Amount exceeded account balance!" Note - keep a copy of your solution to this task because you will be extending it step by step in subsequent tasks. Write the BaseAccount class in the answer box below For example Test Result BaseAccount account new BaseAccount (1122, 20000); 1122: 20000.00 System.out.println(account) )i 1 BaseAccount account2-new BaseAccount (1124, 500 account2.withdraw(-1000); System-out-print in(account2 Amount exceeded account balance! 1124: 500.00
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