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

write a C++ Program in which you will have to write a class ‘Pakistani Citizens’

ID: 3622767 • Letter: W

Question

write a C++ Program in which you will have to write a class ‘Pakistani Citizens’ which has five data members “name, age, CNIC No, province, and domicile” and two data functions getter and setter for each data member e.g setAge() getAge() etc.

Write a second class ‘VotersList’ which inherited the ‘PakistaniCitizens’ class and has “implemented in term of” relationship to pakistaniCitizens.

The ‘VotersList’ class restrict the functionality of setAge() function by override the setAge() function of ‘PakistaniCitizens’ class and check the condition :

If age is greater than 18 then print “Eligible for vote cast”.

If object of VotersList class is initialized with the age less than 18, then it prints a message

“Age is less than 18” and sets the value of age to default.

Explanation / Answer

please rate - thanks

CRAMSTER rule-1 question per post. this is 2

#include <iostream>
using namespace std;
class Pakistani_Citizen
{private:
     string name;
     int age;
     int CNIC_No;
     string province;
     string domicile;
public:
      Pakistani_Citizen(string n,int a,int num,string p,string d)
         {name=n;
         age=a;
         CNIC_No=num;
         province=p;
         domicile=d;
         }
      string getName()
         {return name;}
      void setName(string n)
         {name=n;}
      string getProvince()
         {return province;}
      void setProvince(string p)
         {province=p;}
      string getDomicile()
         {return domicile;}
      void setDomicile(string d)
         {domicile=d;}      
      int getAge()
         {return age;}
      void setAge(int a)
         {age=a;}       
       int getCNIC_No()
         {return CNIC_No;}
      void setCNIC_No(int C)
         {CNIC_No=C;}   
};
int main()
{
Pakistani_Citizen a("John",22,12345,"Ontario","Toronto");
cout<<"person information as initialized: ";
cout<<a.getName()<<" "<<a.getAge()<<" "<<a.getCNIC_No()<<" "<<a.getProvince()<<" ";
cout<<a.getDomicile()<<endl;
a.setName("Mary");
a.setAge(18);
a.setCNIC_No(98765);
a.setProvince("British Columbia");
a.setDomicile("city");
cout<<"person information after changed: ";
cout<<a.getName()<<" "<<a.getAge()<<" "<<a.getCNIC_No()<<" "<<a.getProvince()<<" ";
cout<<a.getDomicile()<<endl;
system("pause");
return 0;
}