Help needed with PHP formula for HW assignment

I need help figuring out the formula to use to find my $change and $newpop. The one I have for $newpop is not calculating correctly. Its either the formulas or something else is wrong. Im not sure which. Here is my php:

Instructions for Homework:
Overview: Write a program to project several years of population growth. The user should be able to enter in the number of years, the current population, and the growth rate. Your output screen should print out the numbers the user entered, as well as the results in a table. Style the table as shown below (though exact colors don’t have to match). Include a link back to the input form. Format the numbers in your output.

You have an unfinished line $change = . What is the formula that is missing there?

I don’t know how to calculate $change. I thought it was $pop - $newpop but that formula wasn’t working. I don’t think my $newpop formula is right either.

Your $newpop formula looks fine. Just switch the $change one around to $newpop - $pop.

But after taht, you want to change $pop to equal the previous $newpop. That way each row is based on the population of the previous row.

If you use $pop all the time, your new population will always be based on the original population. So at the end of the for loop, write $pop = $newpop.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.