// Ch. 18 Demo Program #2
// Mr. Minich
// Purpose - to illustrate the use of recursive functions

#include <iostream>
using namespace std;

double balance(int, double, int);

int main()
{
		int deposit = 0;	// amount of deposit
		int months = 0;		// number of months
		double apr = 0.0;	// annual percentage (interest) rate

		cout << "Enter the initial amount of deposit (integer): ";
		cin >> deposit;
		cout << "Enter the annual interest rate: ";
		cin >> apr;
		cout << "Enter the number of months: ";
		cin >> months;

		cout << "You will have $" << balance(deposit, apr, months) << endl;

		return 0;
}// end of main

double balance(int deposit, double rate, int months)
{
	if (months > 0)
	{
		return ((1 + rate / 12 / 100)  * balance(deposit, rate, months - 1));
	}
	else
	{
		return deposit;
	}
} // end of balance