8. If P is the population of the first day of the year, B is the birth rate and D is the death rate, the estimated population at the end of the year is given by formula: Pn + (B * Pn ) / 100 – ( D * Pn ) / 100 The population growth rate is given by the formula: B - D Write a program that prompts the user to enter the starting population, birth and death rates and n, the number of years. The program should then calculate and print the estimated population after n years. Your program must contain the following functions: GrowthRate: This function takes as its parameters the birth and death rates and returns the population growth rate. Estimated Population: This function takes as its parameters the current population, population growth rate and n, the number of years. It returns the estimated population after n years. Your program should not accept negative birth rate, negative death rate or population less than 2.
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 3 images