Assignment 3
Assignment 3
Task 1
#include<iostream>
using namespace std;
class person{
int id;
string name;
int age;
public:
//setters
void setid()
{
cout<<"Enter your ID:";
cin>>id;
}
void setname()
{
cout<<"Enter your name:";
cin>>name;
void setage()
{
cout<<"Enter your Age:";
cin>>age;
}
//gettersssss
void showid() const
{
cout<<"Entered ID is: "<<id<<endl;
}
void showname() const
{
cout<<" Entered Name is:"<<name<<endl;
}
void showage() const
{
cout<<" Entered Age is:"<<age<<endl;
}
person ()
{
setid();
setname();
setage();
}
};
void setsection()
{
cout<<"Enter your Section:";
cin>>section;
}
//gettersssss
string getsection()
{
return section;
}
string getgender()
{
return gender;
}
void showgender()const{
cout<<"Entred Gender is:"<<gender<<endl;
}
void showcourse_name() const
{
cout<<"Entered Course Name is: "<<course_name<<endl;
}
void showsection() const
{
cout<<" Entered Section is:"<<section<<endl;
}
student ()
{
setsection();
setcourse_name();
setgender();
}
};
class foreign_student: public student{
string country;
string passport_no;
string visa_issue;
string visa_expire;
public:
//setters
void setcountry()
{
cout<<"Enter your Country Name:";
cin>>country;
}
void setpassport_no()
{
cout<<"Enter your Passport No:";
cin>>passport_no;
void setvisa_issue()
{
cout<<"Enter your Visa Issue Date:";
cin>>visa_issue;
}
void setvisa_expire()
{
cout<<"Enter your Visa Issue Date:";
cin>>visa_expire;
}
//gettersssss
string getcountry ()
{
return country;
}
void showcountry() const
{
cout<<"Entered Country Name is: "<<country<<endl;
}
void showpassport_no() const
{
cout<<" Entered Passport Number is:"<<passport_no<<endl;
}
void showvisa_issue() const
{
cout<<" Entered Visa Issue Date is:"<<visa_issue<<endl;
}
void showvisa_expire() const
{
cout<<" Entered Visa Expire Date is:"<<visa_expire<<endl;
}
foreign_student ()
{
setcountry();
setpassport_no();
setvisa_issue();
setvisa_expire();
}
};
int main()
{
char a;
cout<<"Enter 'p' for enter Person,s Data. "<<endl;
cout<<"Enter 's' for enter Student,s Data."<<endl;
cout<<"Enter 'f' for enter Foreign Student,s Data."<<endl;
cin>>a;
switch (a)
{
case 'p':
{
person q;
break;
}
case 's':{
student q;
break;
}
case 'f':{
foreign_student q;
break;
}
default:
cout<<"Invalid Entry";
}
cout<<"Enter 50 Foreign Students Data...."<<endl;
foreign_student q[50];
cout<<"Data of those Foreign Students who are From Turkey,Section 'A' and are Male... "<<endl;
string d,b,c;
for(int i=0;i<50;i++){
d=q[i].getsection();
b=q[i].getcountry();
c=q[i].getgender();
if(c=="m" && b=="turkey" && d=="A")
{
Task 2
#include<iostream>
using namespace std;
class person{
int id;
string name;
int age;
public:
//setters
void setid()
{
cout<<"Enter your ID:";
cin>>id;
}
void setname()
{
cout<<"Enter your name:";
cin>>name;
}
void setage()
{
cout<<"Enter your Age:";
cin>>age;
}
//gettersssss
void showid() const
{
cout<<"Entered ID is: "<<id<<endl;
}
void showname() const
{
cout<<" Entered Name is:"<<name<<endl;
}
void showage() const
{
cout<<" Entered Age is:"<<age<<endl;
}
person ()
{
setid();
setname();
setage();
}
};
class student
{
string course_name;
string section;
string gender;
public:
//setters
void setgender(){
cout<<"Enter your Gender:";
cin>>gender;
}
void setcourse_name()
{
cout<<"Enter your Course name:";
cin>>course_name;
void setsection()
{
cout<<"Enter your Section:";
cin>>section;
}
//gettersssss
string getsection()
{
return section;
}
string getgender()
{
return gender;
}
void showgender()const{
cout<<"Entred Gender is:"<<gender<<endl;
}
void showcourse_name() const
{
cout<<"Entered Course Name is: "<<course_name<<endl;
}
void showsection() const
{
cout<<" Entered Section is:"<<section<<endl;
}
student ()
{
setsection();
setcourse_name();
setgender();
}
};
class foreign_student: public person, public student{
string country;
string passport_no;
string visa_issue;
string visa_expire;
public:
//setters
void setcountry()
{
cout<<"Enter your Country Name:";
cin>>country;
}
void setpassport_no()
{
cout<<"Enter your Passport No:";
cin>>passport_no;
void setvisa_issue()
{
cout<<"Enter your Visa Issue Date:";
cin>>visa_issue;
}
void setvisa_expire()
{
cout<<"Enter your Visa Issue Date:";
cin>>visa_expire;
}
//gettersssss
string getcountry ()
{
return country;
}
void showcountry() const
{
cout<<"Entered Country Name is: "<<country<<endl;
}
void showpassport_no() const
{
cout<<" Entered Passport Number is:"<<passport_no<<endl;
}
void showvisa_issue() const
{
cout<<" Entered Visa Issue Date is:"<<visa_issue<<endl;
}
void showvisa_expire() const
{
cout<<" Entered Visa Expire Date is:"<<visa_expire<<endl;
}
foreign_student ()
{
setcountry();
setpassport_no();
setvisa_issue();
setvisa_expire();
}
};
int main()
{
char a;
cout<<"Enter 'p' for enter Person,s Data. "<<endl;
cout<<"Enter 's' for enter Student,s Data."<<endl;
cout<<"Enter 'f' for enter Foreign Student,s Data."<<endl;
cin>>a;
switch (a)
{
case 'p':
{
person q;
break;
}
case 's':{
student q;
break;
}
case 'f':{
foreign_student q;
break;
}
default:
cout<<"Invalid Entry";
}
cout<<"Enter 50 Foreign Students Data...."<<endl;
foreign_student q[50];
cout<<"Data of those Foreign Students who are From Turkey,Section 'A' and are Male... "<<endl;
string d,b,c;
for(int i=0;i<50;i++){
d=q[i].getsection();
b=q[i].getcountry();
c=q[i].getgender();
if(c=="m" && b=="turkey" && d=="A")
{