Ask Question
18 March, 09:39

Write a program that prompts the user for the initial population sizes, these rates, and the number of years. Then print the populations for the given number of years after your simulation has completed. Hint: This can be accomplished in about 15 lines of code.

+3
Answers (1)
  1. 18 March, 10:30
    0
    The solution code is written in Python:

    pop_size = int (input ("Enter population size: ")) growth_rate = float (input ("Enter growth rate: ")) years = int (input ("Enter number of year: ")) for n in range (1, years + 1) : pop_size = pop_size + (pop_size * growth_rate / 100) print ("Population size after year " + str (n) + ": " + str (pop_size))

    Explanation:

    Firstly, prompt user to input initial population size, growth rate and number of years and assign them to their respective variables (Line 1 - 3).

    Next, create a for-loop to iterate through the number from 1 till the given number of year (Line 5)

    Within the for-loop, apply the formula

    initial population + (initial population * growth rate)

    to estimate the population size after n year (Line 6) and display the output (Line 7).
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a program that prompts the user for the initial population sizes, these rates, and the number of years. Then print the populations ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers