The population of a town A is less than the population of town B.However, the population of
algorithmoutputs after how many years the population of town A will be greater than or equal to
flowchartthat prompts the user to enter the population and growth rate of each town. The
Population of town A =5000, growth rate of town A = 4%, populationof town B = 8000, and
town A is growing faster than the population of town B. Write algorithm usingpseudocodeand
the population of town B and the populations of both the towns at that time. (A sample input is:
growth rate of town B =2%)
function main()
output "Enter the population of town A: "
input populationTownA
output "Enter the population of town B: "
input populationTownB
output "Enter growth rate in percent of town A: "
input growTownA
output "Enter growth rate in percent of town B "
input growTownB
year = 0
if populationTownA <= populationTownB AND growTownA > growTownB then
loop
populationTownA = growTownA / 100 * populationTownA + populationTownA
populationTownB = growTownB / 100 * populationTownB + populationTownB
year = year + 1
while populationTownA <= populationTownB
end loop
output "The Population of town A After " + year + " years is " + populationTownA
output "The Population of town B After " + year + " years is " + populationTownB
else
output "Wrong data"
end If
end function
Comments
Leave a comment