Write a C++ Program that user will define a Class, and you will need to use Vect
ID: 645243 • Letter: W
Question
Write a C++ Program that user will define a Class, and you will need to use Vectors Define a class country as follows: Class: country Define a class called country which has the following private data fields: 1. Name of the country (use the string data type). 2. Population of the country (use the long data type). 3. Area of the country in square kilometers (use the double data type) This class should have the following constructors: 1. A programmer-defined default constructor 2. A programmer-defined constructor that accepts one incoming parameter value for each private field. These incoming parameter values are for initializing a newly created country object. This class should have the following public methods: 1. A get method for each private data field of country. 2. A set method for each private data field of country. 3. A method for deriving the population density of country with the following formula: population density per square kilometer (as a double value) = population / area Program: main () Write a program main () that asks a user for full information of an indefinite number of actual countries until the user chooses to quit. You can assume that the user will enter each piece of information in the correct data type. For example:Explanation / Answer
#include
#include
#define N 100
struct scountry
{
char cname[30];
int population;
double area;
double density;
};
class country
{
private string coname;
private long int popu;
private double area;
pbblic double popden;
public:
void country()
{
}
void country(string a, long int b, double c)
{ coname=a;
popu=b;
area=c;
}
string getName()
{return coname;
}
void setName(string coname)
{this.coname=coname;
}
long int getPop()
{return popu;
}
void setPop(long int popu)
{this.popu=popu;
}
double getArea()
{return area;
}
void setArea(double area)
{this.area=area;
}
double PopDen(double popu,double area)
{this.popu=popu;
this.area=area;
popden=popu/area;
return popden;
}
};
int main()
{int i=0;
country cc;
double den;
char ch;
struct student record[N];
do
{cout<<
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.