Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m getting an Error : LNK1561: entry point must be defined. Can someone edit i

ID: 3678377 • 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 <iomanip>

#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

The following program is compiled and is in 100% working condition. I have commented for your understanding. If you still don't get anything, please comment so that i can explain.

#include <iostream>
#include <iomanip>
using namespace std;

class Pop //declare a class
{
private:
int population; //member variables
int births;
int deaths;

public:
void setPopulation(int); //function prototypes
void setBirths(int);
void setDeaths(int);

int getPopulation();
double getBirthRate();
double getDeathRate();

Pop():
population(0),
births(0),
deaths(0) {
} };


void Pop::setPopulation(int p) {population = p;
}

void Pop::setBirths(int b) {births = b;}

void Pop::setDeaths(int d) {deaths = d;
}

int Pop::getPopulation(){return population;
}

double Pop:: getBirthRate()
{return births/static_cast <double>(population);
}

double Pop::getDeathRate()
{
return deaths/static_cast <double>(population);
}


int main()
{
Pop myTown;
int numPeople;
int numBirths;
int numDeaths;


cout<<"Enter the total population ";
cin>>numPeople;

while(numPeople < 1)
{
cout<<"value must be greater than 0, please re-enter ";
cin>>numPeople;
}

myTown.setPopulation(numPeople);
cout<<"Enter annual number of births ";
cin>>numBirths;

while(numBirths < 0)
{
cout<<"value cannot be negative, please re-enter ";
cin>>numBirths;
}

myTown.setBirths(numBirths);
cout<<"Enter annual number of deaths ";
cin>>numDeaths;

while(numDeaths < 0)
{
cout<<"value cannot be negative, please re-enter ";
cin>>numDeaths;
}

myTown.setDeaths(numDeaths);

cout<<"population statistics ";
cout<<fixed<<showpoint<<setprecision(3);

cout<<" Population: " <<setw(7)<<myTown.getPopulation();

cout<<" Birth rate: "<<setw(7)<<myTown.getBirthRate();
cout<<" Death Rate: "<<setw(7)<<myTown.getDeathRate()<<endl;

return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote