PopulationGrowth Program
Description
Two schools have different populations and projected growth rates. Assume that school one has less population than school two, but has higher projected growth rate.This program determines the number of years school one will have greater population than school two.
Associated Concepts:
while loop
Algorithm:
Input populations and projected growth rates
for school one and school two
Set the variable year to 0
Use a while to check the relation between population one and population two
(as long as population one is less than population two)
Calculate the new populations of both schools by incorporating the growth rates for the next year
Increment the variable year by 1
Once the while loop is ended, the variable year holds the answer.
Set the variable year to 0
Use a while to check the relation between population one and population two
(as long as population one is less than population two)
Calculate the new populations of both schools by incorporating the growth rates for the next year
Increment the variable year by 1
Once the while loop is ended, the variable year holds the answer.