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

Write a C++ program: Write a class to contain the following information about to

ID: 3864824 • Letter: W

Question

Write a C++ program:

Write a class to contain the following information about towns: the name (a sequence of characters); the population (an integer); and a Boolean value (i.e. true or false) which indicates whether the town has an airport or not. Make the three data members private. Include a constructor that initialises the data members. And Now add three new member functions to the towns class that assign values to the three data members. Also add a member function to print out all the information about a town. The member functions should all be publicly accessible. Write a main() function which declares three town objects and assigns the following values to them:

Population:   1 000 000 50 000 35 000

Airport:   True True False

After assigning values to the three objects, the program should print the details of thoose three to the screen.

Explanation / Answer

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

class towns {

private:
string name; // Name of Town
int population; // Population of town
bool airport; //true or false value for airport
town( ); //Constructor
};

int main()
{
cout<<"Enter Town, population and airport value"<<end l;
if(town.name=LONDON)
{
cout<<"population=1000000 and airport = true"<<end l;
}
elseif(town.name=MANCHESTER)
{
cout<<"population=50000 and airport=true"<<end l;
}
else
{
cout<<"population=35000 and airport=false"<<end l;
}
}

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