Ask Question

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.

+5
Answers (1)
  1. 31 December, 04:19
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers