I have to write a program using accessors and mutators and a constructor that stores a savings account's annual interest rate and balance. The class constructor needs to accept the amount of the savings account's starting balance. The class needs to have methods for subtracting withdrawals, adding deposits, and adding the amount of monthly interest rate to the balance. The program should ask the user for the amound deposited into the account during the month, ask the user for teh amount withdrawn from the account during the month, and use the class method to calculate the monthly interest. After the last iteration, the program needs to display teh ending balance, the total amount of deposits, the total amount of withdrawals, and the total interest earned. The code below is what I have so far, and I could use some input as to where to go from here:
public class SavingsAccount // Begin public class SavingsAccount
{ // Instance Variables
private double balance; // Account Balance
private double withdrawals; // Account Withdrawals
private double deposits; // Account Deposits
private double rate; // Interest Rate
// Constructor Method Here
public SavingsAccount(double balance, double withdrawals, double deposits, double rate)
{ // Begin public SavingsAccount(double balance, double withdrawals, double deposits, double rate)
balance = 0;
withdrawals = 0;
deposits = 0;
rate = 0;
} // End public SavingsAccount(double balance, double withdrawals, double deposits, double rate)
// Accessor- Gets the beginning balance
public double getBalance()
{
return balance;
} // End public double getBalance()
// Accessor- Gets monthly deposits
public double getDeposits()
{
return deposits;
} // End public double getDeposits()
// Accesor- Gets monthly withdrawals
public double getWithdrawals()
{
return withdrawals;
} // End public double getWithdrawals()
// Accessor- Gets interest rate
public double getRate()
{
return rate;
} // End public double getRate()
// Calculate balance with deposits
public void setBalance(double deposits)
{
balance += balance;
} // End public void setBalance(double deposits)
// Calculate balance with withdrawals
public void setBalance(double withdrawals)
{
balance -= balance;
} // End public void setBalance(double withdrawals)
// Calculate monthly interest rate
public void setBalance(double rate)
{
balance += rate;
} // End public void setBalance(double rate)
} // End public class SavingsAccount