Question
I'm getting an Error : LNK1561: entry point must be defined . Can someone edit it with using the basic iostream and string libraries, only
I'm getting an Error: LNK1561: entry point must be defined. Can someone edit it with using the basic iostream and string libraries, only basic lib.
In a population, the birth rate and death rate are calculated as follows: Birth Rate = Number of Births Population Death Rate = Number of Deaths Population For example, in a population of 100,000 that has 8,000 births and 6,000 deaths per year, 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 some geographic area. The class should allow these three values to be set in either of two ways: by passing arguments to a three-parameter constructor when a new Population object is created or by calling the setPopulation, setBirths, and setDeaths class member functions. The class should also have getBirthRate and getDeathRate functions that compute and return the birth and death rates. Write a short program that uses the Population class and illustrates its capabilities. Input Validation: If a population figure less than 2 is passed to the class, use a default value of 2. If a birth or death figure less than 0 is passed in, use a default value of 0
#include
using namespace std;
class Population { private: int curPopulation; int annualBirths; int annualDeaths;
public: Population(); Population(int p, int b, int d); void setPopulation(int pop); void setBirths(int births); void setDeaths(int deaths); double getBirthRate(); double getDeathRate(); };
Population::Population() { };
Population::Population(int a, int b, int c) { if (a>=2) {
} else p=2; //cout<
if(c<0) { annualDeaths=0; } else annualDeaths = c; //cout<
Population::setBirths(int b) { if(b<0) { annualBirths=0; } else annualBirths = b; }
Population::setDeaths(int d) { if(d<0) { annualDeaths=0; } else annualDeaths = d; }
Population::getBirthRate() { double c = curPopulation; double b = annualBirths; double br = 0; br = b/c; cout << "The Birth rate is:" << br << endl; return br; }
Population::getDeathRate() { double c = curPopulation; double d = annualDeaths; double dr = 0; dr = d/c; //dr = (numDeaths/ curPopulation); cout << "The Death rate is:" << dr << endl; return dr; }
int main(){
double d=0; Population p1 = Population(100000, 8000,6000); d =p1.getBirthRate(); d = p1.getDeathRate(); cout << endl;
Population p2 = Population(); int temp; cout<<"Enter the poulation: "; cin >> temp; p2.setPopulation(temp); cout << "Enter the number of Births: "; cin >> temp; p2.setBirths(temp); cout << "Enter the number of Deaths: "; cin >> temp; p2.setDeaths(temp); cout << endl; p2.getBirthRate(); p2.getDeathRate(); cout << endl;
return 0; };
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started