Modify your Module 1 Lab Assignment Create a new class Inves
Modify your Module 1 Lab Assignment. Create a new class InvestmentSavingsAccount.java class that extends the SavingsAccount class.
Your investment savings class will have an InvestmentSavingsAccount constructor with one argument . If the deposit is more than $1000, the deposit will earn 2.0% in interest. You will need to create new methods to get the investment interest rate, set the new savings account balance and override the toString() method for the SavingsAccount class. Your new toString() method will return a formatted string with the original savings amount and the investment savings amount.
Use the CommissionEmployee example in the text to assist you in completing this assignment.
NEW CLASS - InvestmentSavingsAccount.java
// Module 2 Assignment - InvestmentSavingAccount
// InvestmentSavingAccount class definition
public class InvestmentSavingsAccount extends SavingsAccount{
// Declare global variable annual interest rate
// Declare global variable investment balance
// constructor, create a one arguement constructor for investment savings account.
// If investment balance is greater than 1000, assign value of investment balance to this investment balance
//else print \"investment balance must be at least $1000\"
//modify the interest rate
//if the new interest rate is equal to 2, set the annual interest rate equal to the new interest rate, else print error message \"rate must be 2.0\"
// calculate the investment balance and monthly interest based on investment balance and annual Interest Rate
// the investment balance is equal to the current investment balance plus the new investment balance times annual Interest Rate divided by 12.0
@Override //indicates that this methods overrides a superclass method
// get string representation of investment balance
//return the investment balance value and interest rate as a formatted string
} // end class InvestmentSavingsAccount
MODIFY CLASS - SavingsAccountTest.java
Modify the the SavingsAccountTest class. Create an InvestmentSavingsAccount object and execute the same methods executed for the SavingsAccount object in Module 1 Assignment.
Solution
Hi, Friend, You have not posted SavingsAccount.java and SavingsAccountTest.java .
Please post all the details.
I have implemented based on information given in question.
public class InvestmentSavingsAccount extends SavingsAccount{
// Declare global variable annual interest rate
private double interestRate;
// Declare global variable investment balance
private double balance;
// constructor, create a one arguement constructor for investment savings account.
public InvestmentSavingsAccount(double balance){
// If investment balance is greater than 1000, assign value of investment balance to this investment balance
if(balance > 1000){
this.balance = balance;
interestRate = 2.0; // investment balance more than 1000
}
//else print \"investment balance must be at least $1000\"
else
System.out.println(\"investment balance must be at least $1000\");
// annual interet rate information might be given in SavingAccount class
}
@Override //indicates that this methods overrides a superclass method
// get string representation of investment balance
//return the investment balance value and interest rate as a formatted string
public String toString(){
return super.toString()+\", investment balance: \"+balance+\", interest rate: \"+interestRate;
}
} // end class InvestmentSavingsAccount

