// Investment.java
// with Javadoc comments by Prof. Payne

/** Investment computes a future balance based on monthly investment, APR, and # of years. */
public class Investment
{
	// fields
	/** Number of years to invest. */
	int years;
	/** Monthly amount to invest. */
	double investment;
	/** Annual interest rate. */
	double interest;
	/** Balance after all that time. */
	double balance;

	// constructor
	/** Constructs an investment with the given APR, amt, & #yrs.
		@param interestRate an annual APR.
		@param investAmt an amount to invest each month.
		@param numYears how many years to invest.
		*/
	public Investment(double interestRate, double investAmt, int numYears)
	{
		balance = 0;
		interest = interestRate;
		investment = investAmt;
		years = numYears;
	}

	// methods
	/** Computes the future balance of the simulated investment. */
	public void run()
	{
		for(int x=1; x<=years; x++)
			for(int y=0; y<12; y++)
			{
				balance = balance *(1+(interest/100/12));
				balance = balance + investment;
			}
	}

	/** Returns the future balance after running the investment.
		@return the future balance.
		*/
	public double getBalance()
	{
		return balance;
	}
}

