Question
PART A) Create class Account. Account has an id. Each object of the class contains a private instance variable savingsBalance indicating the amount the saver
PART A) Create class Account. Account has an id. Each object of the class contains a private instance variable savingsBalance indicating the amount the saver currently has on deposit.
SavingsAccount is an Account with additional features. Use a static variable annualInterestRate to store the annual interest rate for all account holders. Provide method calculateMonthlyInterest to calculate the monthly interest by multiplying the savingsBalance by annualInterestRate divided by 12, this interest should be added to savingsBalance. Provide a static method modifyInterestRate that sets the annualInterestRate to a new value.
Write a program to test your code. Instantiate two savingsAccount objects, saver1 and saver2, with balances of $2000.00 and $3000.00, respectively. Set annualInterestRate to 4%, then calculate the monthly interest and print the new balances for both savers. Then set the annualInterestRate to 5%, calculate the next months interest and print the new balances for both savers.
PART B) Imagine you have two classes: Employee (which represents being an employee) and Ninja (which represents being a Ninja). An Employee has both state and behaviour; a Ninja has only behavior. You need to represent an employee who is also a ninja (a common problem in the real world). By creating only one interface and only one class (NinjaEmployee), show how you can do this without having to copy method implementation code from either of the original classes. Test your code in main method.
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