Question: JAVA Create class SavingsAccount. Use a static variable annualInterestRate to store the annual interest rate for all account holders. Each object of the class contains
JAVA
Create class SavingsAccount. Use a static variable annualInterestRate to store the annual interest rate for all account holders. Each object of the class contains a private instance variable savingsBalance indicating the amount the saver currently has on deposit. 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 class SavingsAccount. 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.
a) Create a super class called Car. The Car class has the following fields and methods:
Int speed;
double regularPrice;
String color;
double getSalePrice();
b) Create a subclass of Car class and name it as Truck. The Truck class has the following fields and methods:
int weight;
double getSalePrice();
* If weight > 2000, 10% discount. Otherwise, 20% discount.
c) Create a subclass of Car class and name it as Ford. The Ford class has the following fields and methods:
int year;
int manufacturerDiscount;
double
* From the sale price computed from Car class, subtract the manufacturerDiscount.
d) Create a subclass of Car class and name it as Sedan. The Sedan class has the following fields and methods:
int length;
double getSalePrice();
* If length > 20 feet, 5% discount, Otherwise, 10% discount.
e) Create MyOwnAutoShop class which contains the main() method. Perform the following within the main() method:
Create an instance of Sedan class and initialize all the fields with appropriate values. Use super(...) method in the constructor for initializing the fields of the superclass.
Create two instances of the Ford class and initialize all the fields with appropriate values. Use super(...) method in the constructor for initializing the fields of the super class.
Create an instance of Car class and initialize all the fields with appropriate values. Display the sale prices of all instance.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
