Ask Question
14 October, 18:54

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.

+1
Answers (1)
  1. 14 October, 20:16
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers