subject

Populations are effected by the birth and death rate, as well as the number of people who move in and out each year. the birth rate is the percentage increase of the population due to births and the death rate is the percentage decrease of the population due to deaths. write a program that displays the size of a population for any number of years. the program should ask for the following data:
the starting size of a population p
the annual birth rate (as a percentage of the population expressed as a fraction in decimal form)b
the annual death rate (as a percentage of the population expressed as a fraction in decimal form)d
the average annual number of people who have arrived a
the average annual number of people who have moved away m
the number of years to display nyears
write a function that calculates the size of the population after a year. to calculate the new population after one year, this function should use the formula
n = p + bp - dp + a - m
where n is the new population size, p is the previous population size, and b, d, a and m are as defined above. the function should return the value computed for n and should receive the values of p, b, d, a and m as parameters.
prompts and output labels. the program first displays the message "this program calculates population change." on a line by itself, followed by these prompts for the inputs described above: "enter the starting population size: "
"enter the annual birth rate (as % of current population): "
"enter the annual death rate (as % of current population): "
"how many individuals move into the area each year? ";
"how many individuals leave the area each year? ";
"for how many years do you wish to view population changes? "
the output of the program starts with a line:
starting population: p (where p is the starting population ( and then continues with a separate line for each year, each line being of the form: population at the end of year ||y is p. (where y is the year number (1,2, starting with 1, and where p is the population calculated for that year).
input validation. the program should validate all data read. none of the data should be negative, the number of years should not be less than 1 and the initial population should not be less than 2. if an invalid value is read, the program should print an error-specific message on a line by itself, followed by the directive " re-enter: " and then input another value-- until a valid value is entered. the error specific messages are: "starting population must be 2 or more.", "birth rate percent cannot be negative.", "death rate percent cannot be negative.", "arrivals cannot be negative.", "departures cannot be negative.", and "years must be one or more.".

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 12:10
1. package newton’s method for approximating square roots (case study 3.6) in a function named newton. this function expects the input number as an argument and returns the estimate of its square root. the script should also include a main function that allows the user to compute square roots of inputs until she presses the enter/return key. 2. convert newton’s method for approximating square roots in project 1 to a recursive function named newton. (hint: the estimate of the square root should be passed as a second argument to the function.) 3. elena complains that the recursive newton function in project 2 includes an extra argument for the estimate. the function’s users should not have to provide this value, which is always the same, when they call this function. modify the definition of the function so that it uses a keyword parameter with the appropriate default value for this argument, and call the function without a second argument to demonstrate that it solves this problem. 4. restructure newton’s method (case study 3.6) by decomposing it into three cooperating functions. the newton function can use either the recursive strategy of project 1 or the iterative strategy of case study 3.6. the task of testing for the limit is assigned to a function named limitreached, whereas the task of computing a new approximation is assigned to a function named improveestimate. each function expects the relevant arguments and returns an appropriate value. 5. a list is sorted in ascending order if it is empty or each item except the last one is less than or equal to its successor. define a predicate issorted that expects a list as an argument and returns true if the list is sorted, or returns false otherwise. (hint: for a list of length 2 or greater, loop through the list and compare pairs of items, from left to right, and return false if the first item in a pair is greater.)
Answers: 1
question
Computers and Technology, 22.06.2019 21:30
Im doing this last minute and literally none of my neighbors or people that my dad works with use excel so if anyone could me make up an example
Answers: 1
question
Computers and Technology, 23.06.2019 06:00
Respond to the following in three to five sentences. select the workplace skill, habit, or attitude described in this chapter that you believe is most important for being a successful employee.
Answers: 1
question
Computers and Technology, 24.06.2019 00:40
What social factors affect your health
Answers: 3
You know the right answer?
Populations are effected by the birth and death rate, as well as the number of people who move in an...
Questions
question
Mathematics, 01.12.2020 01:00
question
Mathematics, 01.12.2020 01:00
question
Mathematics, 01.12.2020 01:00
Questions on the website: 13722361