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

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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