the purpose of this class file is to design a Saving account that stores a saving account's annual interest rate and balance. I have not wrote the test program yet, seeing that I believe I made a few mistakes with my class file. Also, at the end of classfile, I hid a method because I didn't understand how to word that method to add the interest rate to the balance.
Here are some additional information that could help you understand where I was going.
Name of class :SavingAccount Class
The Constructor should accept the amount of the savings account's starting balance.
Methods:
-Subtracting the amound of withdrawal.
-Adding the amound of a deposit.
-Adding the amount of monthly interest to the balance.
Other information:
- The annual rate is 5% (.05)
-monthly interest = Annual interest rate divided by 12.
- Getting the monthly interest rate added to balance: Add the monthly rate to the balance. With the new result, add to the balance.
Class File
public class SavingsAccount
{
private double balance;
private double startBalance;
private double AnnualRate = 0.5;
private double MonthlyInterest;
private double withdrawl;
private double NewWithdrawl;
private double deposit;
private double NewDeposit;
public SavingsAccount()
{
balance = 0.0;
}
public SavingsAccount(double startBalance)
{
balance = startBalance;
}
public double getAnnualRate()
{
return AnnualRate;
}
public double MonthlyInterest()
{
MonthlyInterest= AnnualRate/12;
return MonthlyInterest;
}
public double getWithdrawl()
{
NewWithdrawl = balance - withdrawl;
return NewWithdrawl;
}
public double deposit()
{
NewDeposit = balance + deposit;
return NewDeposit;
}
/* ( The objecttive is to "Add the amount of monthly interest to the balance", not sure where this was going)
public getMonthlyInterestRate()
{
MonthlyBalance = MonthlyInterest x balance;
NewMonthlyBalance = MonthlyBalance + balance;
return NewMonthlyBalance;
}
*/
}
Thanks for going through what I wrote, I hope I didn't make a huge mistake with my class file.