I\'m getting an Error : LNK1561: entry point must be defined . Can someone edit
ID: 3677993 • Letter: I
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 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 <iostream>
#include <string>
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<<curPopulation<<endl;
if(b<0)
{
annualBirths=0;
}
else
annualBirths = b;
//cout<<numBirths<<endl;
if(c<0)
{
annualDeaths=0;
}
else
annualDeaths = c;
//cout<<numDeaths<<endl;
};
Population::setPopulation(int p)
{
if(p >= 2)
{
curPopulation = p;
}
else
p=2;
}
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;
};
Explanation / Answer
#include <iostream>
#include <string>
#include<iomanip>
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();
};
void Population::setPopulation(int p)
{
if(p >= 2)
{
curPopulation = p;
}
else
p=2;
}
void Population::setBirths(int b)
{
if(b<0)
{
annualBirths=0;
}
else
annualBirths = b;
}
void Population::setDeaths(int d)
{
if(d<0)
{
annualDeaths=0;
}
else
annualDeaths = d;
}
double Population::getBirthRate()
{
double c = curPopulation;
double b = annualBirths;
double br = 0;
br = b/c;
cout << "The Birth rate is:" << br << endl;
return br;
}
double Population::getDeathRate()
{
double c = curPopulation;
double d = annualDeaths;
double dr = 0;
dr = d/c;
cout << "The Death rate is:" << dr << endl;
return dr;
}
Population::Population(void)
{
}
Population::Population(int a, int b, int c)
{
if (a<2)
{
p=2;
}
if(b<0)
{
annualBirths=0;
}
else
annualBirths = b;
if(c<0)
{
annualDeaths=0;
}
else
annualDeaths = c;
}
int main()
{
double d=0;
Population p1 = Population(100000, 8000,6000);
double d1, d2;
d1 =p1.getBirthRate();
d2 = p1.getDeathRate();
cout << endl;
Population p2;
int temp1,temp2,temp3;
cout<<"Enter the poulation: ";
cin >> temp1;
p2.setPopulation(temp1);
cout << "Enter the number of Births: ";
cin >> temp2;
p2.setBirths(temp2);
cout << "Enter the number of Deaths: ";
cin >> temp3;
p2.setDeaths(temp3);
cout << endl;
double d3,d4;
d3= p2.getBirthRate();
d4=p2.getDeathRate();
cout << endl;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.