In a population, the birth rate and death rate are calculated asfollows: Birth r
ID: 3610277 • Letter: I
Question
In a population, the birth rate and death rate are calculated asfollows: Birth rate = Number of Births /population death rate = number of deaths / population for example, in a population of 100,000 that has 8,000 birthsand 6,000 deaths per year, the birth rate and death rate are birth rate = 8,000 / 100,000 = 0.08 death rate = 6,000 / 100,000 = 0.06 design a population class that stores a current population,annual number of births, and annual number of deaths for somegeographic area. The class should allow these three values to beset in either of two ways: by passing arguments to athree-parameter constructor when a new Population object is createdor by calling the setPupulation, setBirths, and setDeaths memberfunctions provided by the class. The class should also have twomember finctions, getBirthRate and getDeathRate, that compute andreturn the birth and death rates. Write a short program that usesthe Population class and illustrates its capabilities. Input validation: if a pupulation figure less then 2 is passedto the class, a default value of 2 should be used. If a birth ordeath figure less than 0 is passed to the class, a degault value of0 should be used Birth rate = Number of Births /population death rate = number of deaths / population for example, in a population of 100,000 that has 8,000 birthsand 6,000 deaths per year, the birth rate and death rate are birth rate = 8,000 / 100,000 = 0.08 death rate = 6,000 / 100,000 = 0.06 design a population class that stores a current population,annual number of births, and annual number of deaths for somegeographic area. The class should allow these three values to beset in either of two ways: by passing arguments to athree-parameter constructor when a new Population object is createdor by calling the setPupulation, setBirths, and setDeaths memberfunctions provided by the class. The class should also have twomember finctions, getBirthRate and getDeathRate, that compute andreturn the birth and death rates. Write a short program that usesthe Population class and illustrates its capabilities. Input validation: if a pupulation figure less then 2 is passedto the class, a default value of 2 should be used. If a birth ordeath figure less than 0 is passed to the class, a degault value of0 should be usedExplanation / Answer
#include #include //#include using namespace std; //class declaration class Population { private: int curPopulation; int numBirths; int numDeaths; public: Population(); Population(int p, int b, intd); void setPopulation(intpop); void setBirths(intbirths); void setDeaths(intdeaths); double getBirthRate(); double getDeathRate(); }; //class implementation Population:: Population() { } Population:: Population(int p, int b, int d) { if(p >= 2) { curPopulation = p; } else p=2; //coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.