Assignment 2
Advanced PHP: The Investment Calculator Assignment

1. Create a Calculator page (and link to it from the main page of your site).

2. For the Calculator page, you're going to program a simple investment calculator.

3. Use the following function (which you can copy and paste into your page):

function calculate_future_value ($monthly=100.0, $rate=0.10, $numyears=30){
	$total = 0;
	for ($counter=1; $counter <= $numyears*12; $counter++) {
		$total*=1+$rate/12;
		$total+=$monthly;
	}
	return $total;
}

4. If a person has not submitted any values (or at least a monthly amount), show a nicely formatted form asking for a monthly investment amount(100.0 for $100.00), an annual rate of return (such as 0.10 for 10%), and a number of years to simulate investing (how many years to retirement). Label the Submit button "Calculate".

5. If values have been submitted, display something like the following:

Investing $100.00 per month at an annual rate of 10.0% for 30 years, you'll retire with $226,048.79.
Would you like to try a different investment scenario?

And, display the form with their previous entries already filled in.

6. Add a link to email the results of this form to an email address, and show a text field that accepts the email address (You will only be able to email GCSU accounts - like bobcat). 

For a sample, working version of the calculator only, go to http://iscm.gcsu.edu/~bpayne/ch3/calculator.php

[Options: Set the cursor flashing in their Monthly Investment Amount textbox each time the page is loaded.]


©2005 - Bryson R. Payne, Ph.D. - All rights reserved.