Write a program that displays the size of a population

Assignment Help C/C++ Programming
Reference no: EM13705325

Transient Population:

 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 (surprise)), 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,3,...) 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 "Please 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.".

Reference no: EM13705325

Questions Cloud

Determine how to best maximize the amount of net fixed asset : Analyze the accounting for each fixed asset class using US GAAP and IFRS and determine how to best maximize the amount of net fixed assets.
Change in internal energy of nitrogen in a process : Saturated liquid water at 1.0 MPa is inside a piston­cylinder device, which is heated until all of the water is vaporized. Find the amount of heat transfer needed for this process. Find the change in enthalpy and the change in internal energy of nitr..
Program to report on the roots of a quadratic equation : Write a complete C++ program to report on the roots of a quadratic equation ax2 + bx + c = 0, a ≠ 0. compute the roots.
The mass flow rate of the refrigerant : A small vapor-compression refrigeration unit is to be built into a recreational vehicle and is designed to operate on a 12-volt electrical system. The refrigerator has a cooling capacity of 500 W and uses R-134a. The refrigerant enters the compressor..
Write a program that displays the size of a population : Write a function that calculates the size of the population after a year. To calculate the new population after one year.
Money was made in interest over the initial investment : If a single deposit of $25000 is invested at 1.75% yearly interest, what equal year-end withdrawals can be made each year for 10 years, leaving nothing in the fund after the 10th withdrawal? How much money was made in interest over the initial invest..
Measurement of the flow rate of a stream of liquid acetone : An orifice meter is to be calibrated for the measurement of the flow rate of a stream of liquid acetone. The differential manometer fluid has a specific gravity of 1.10. The calibration is accomplished by connecting the orifice meter in series with a..
Find a simplified form for the probability function : Give the probability function for the number of defective pens in a package - determine the probability that a customer will demand his/her money back - Provide a reasonable estimate with justification for the value of N.
Constant gravitational acceleration : A 2 lb rocket is launched from the ground, with its launch rail elevated at an angle of 70° from ground, with zero initial speed. Assuming its motor provide a thrust force T = 25 lb for the period of 0 _ 0.1 s, no air resistance, constant gravitatio..

Reviews

Write a Review

C/C++ Programming Questions & Answers

  C program to mips program

Convert the following C program to MIPS program. Assuming that i, j, k, f, are stored in registers $s0, $s1, $s2, $s3 already. The base address of arrays A and B are in registers $s4 and $s5, respectively. (30

  Write a program that takes data a line at a time

Write a program that takes data a line at a time and reverses the words of the line

  Add a copy constructor

Take the code below and add a copy constructor, assignment operator definition and destructor to the class. These functions have already been started for you.

  Discuss the differences concerning how a program would acces

Discuss the differences concerning how a program would access the members of objects that have been declared as an array of objects

  Design and implement a c program and structure diagram for

design and implement a c program and structure diagram for the subsequent specification.show writing and calling

  Extend the definition of the class clocktype by overloading

a. Extend the definition of the class clockType by overloading the post-increment operator function as a member of the class clockType

  Maze program

Maze program. In this assignment you will represent a maze with a binary tree. . The starting point is node N and the ending point is node Z.

  Composite data types (arrays & records)

Composite data types (arrays & records) can be a problem when they are passed as parameters or returned by functions. Why?

  If ptr is a pointer to a character

If ptr is a pointer to a character and has been initialized to point to the first element of arr, write a statement using ptr that is equivalent to the statement array[4] = 12.

  Lists of integers and displays whether the two are identical

Write a test program that prompts the user to enter two lists of integers and displays whether the two are identical. Here are the sample runs.

  Assignment 1 boxing amoebadevelop a two dimensional

assignment 1 boxing amoebadevelop a two dimensional interactive game with the following features1.use opengl any

  How many generations do you want to wait

How many generations do you want to wait? How many jackalopes do you have?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd