Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
public class InterestAccount {
private double balance;
private double interest;
// Constructors
public InterestAccount (double initialBalance, double initialInterest) {
this.balance = initialBalance;
this.interest = initialInterest;
}
// Getters and Setters
public double getBalance () { return this.balance; }
public void setBalance (double bal) { this.balance = bal; }
public double getInterest () { return this.interest; }
public void setInterest (double interest) { this.interest = interest; }
// Other member functions
/**
* Accrue account balance by one year's interest
* @return Account balance after the accrual
*/
public double accrue () {
this.balance = balance + (balance * interest);
return this.balance;
}
/**
* Accrue account balance by specified years of interest
* @param y Number of years to accrue
* @return Account balance after accrual
*/
public double accrueYears (int y) {
while (y != 0) {
accrue();
y--;
}
return this.balance;
}
}