You are on page 1of 2

public class SavingsAccount

private double balance;

private double interestRate;

private double monthlyInterestRate;

private double finalInterest;

// This constructor gets starting balance and interest rate

public SavingsAccount(double bal, double intRate)

balance = bal;

interestRate = intRate;

//The deposit method adds the deposits to the balance

public void deposit(double total)

balance += total;

//The withdraw method subtracts the withdraw amount from balance

public void withdraw (double total)

balance -= total;

//Calculates the interest rate

public void interest ()

monthlyInterestRate = ((interestRate / 100) / 12);

finalInterest = monthlyInterestRate * balance;

balance += finalInterest;

}
public void setBalance (double sb)

balance = sb;

public double getBalance()

return balance;

public double getInterestRate()

return interestRate;

public double getFinalInterest()

return finalInterest;

public static void main (String[] args) {

You might also like