Professional Documents
Culture Documents
VUAnswer.com
Total Marks: 20
Due Date: 15 Feb 2022
CODE Solution:
#include <iostream>
#include <conio.h>
using namespace std;
class person
VUAnswer.com
{
private:
int age;
string name;
string gender;
string address;
string phone;
public:
person()
{
age=0;
name="";
gender="";
address="";
phone="";
}
void setAge()
{
VUAnswer.com
cout<<"\nEnter Age: ";
cin>>age;
}
void setName()
{
cout<<"\nEnter Name: ";
cin>>name;
}
void setGender()
{
cout<<"\nEnter Gender: ";
cin>>gender;
}
void setAddress()
{
cout<<"\nEnter Address: ";
cin>>address;
}
VUAnswer.com
void setPhone()
{
cout<<"\nEnter Phone number: ";
cin>>phone;
}
int getAge()
{
return age;
}
string getName()
{
return name;
}
string getGender()
{
return gender;
}
string getAddress()
VUAnswer.com
{
return address;
}
string getPhone()
{
return phone;
}
void Save_Information()
{
setName();
setGender();
setAge();
setAddress();
setPhone();
}
void Display_Information()
{
cout<<"Name: "<<getName()<<endl;
VUAnswer.com
cout<<"Gender: "<<getGender()<<endl;
cout<<"Age: "<<getAge()<<endl;
cout<<"Address: "<<getAddress()<<endl;
cout<<"Phone: "<<getPhone()<<endl;
}
};
class Teacher:public person
{
private:
string qualification;
float salary;
public:
Teacher()
{
qualification="";
salary=0.0;
}
void setQualification()
VUAnswer.com
{
cout<<"\nEnter Qualification: ";
cin>>qualification;
}
void setSalary()
{
cout<<"\nEnter Salary: ";
cin>>salary;
}
string getQualification()
{
return qualification;
}
float getSalary()
{
return salary;
}
void Save_Information()
VUAnswer.com
{
person::Save_Information();
setQualification();
setSalary();
}
void Display_Information()
{
person::Display_Information();
cout<<"Qualification: "<<getQualification()<<endl;
cout<<"Salary: "<<getSalary()<<endl;
}
};
VUAnswer.com
string previousEducation;
public:
student()
{
totalMarks=0.0;
obtainedMarks=0.0;
previousEducation="";
}
void setTotalMarks()
{
cout<<"\nEnter Total Marks: ";
cin>>totalMarks;
}
void setObtainedMarks()
{
cout<<"\nEnter Obtained Marks: ";
cin>>obtainedMarks;
}
VUAnswer.com
void setPreviousEducation()
{
cout<<"\nEnter Previous Education: ";
cin>>previousEducation;
}
float getTotalMarks()
{
return totalMarks;
}
float getObtainedMarks()
{
return obtainedMarks;
}
string getPreviousEducation()
{
return previousEducation;
}
void Save_Information()
VUAnswer.com
{
person::Save_Information();
setPreviousEducation();
setTotalMarks();
setObtainedMarks();
}
void Display_Information()
{
person::Display_Information();
cout<<"Previous Education: "<<getPreviousEducation()<<endl;
cout<<"Total Marks: "<<getTotalMarks()<<endl;
cout<<"Obtained Marks: "<<getObtainedMarks()<<endl;
}
};
main()
{
int x=0;
int y=0;
VUAnswer.com
char choice;
char z;
Teacher *T[5];
Student *S[5];
cout<<"Enter choice: T For Teacher, S For Student: ";
cin>>choice;
if(choice == 'T' || choice == 't')
{
cout<<""<<endl;
cout<<"Enter Following Data for Teacher: "<<endl<<endl;
do {
T[x]=new Teacher;
T[x]->Save_Information();
x++;
cout<<"Do You Want to Enter More Data(Y for Yes,N for No):
"<<endl<<endl;
cin>>z;
}
VUAnswer.com
while (z=='y'|| z=='Y');
cout<<"Display Teacher Information:"<<endl<<endl;
cout<<"----------------------------"<<endl;
for(int p=0; p<x; p++)
T[p]->Display_Information();
}
else
{
cout<<"Enter Following Data For Student:"<<endl<<endl;
do {
S[y]=new Student;
S[y]->Save_Information();
y++;
cout<<"Do You Want to Enter More Data(Y for Yes || N for
NO):"<<endl<<endl;
cin>>z;
}
while (z=='Y'|| z=='y');
VUAnswer.com
cout<<"Display Student Information:"<<endl<<endl;
cout<<"----------------------------"<<endl;
for(int p=0; p<y; p++)
S[p]->Display_Information();
}
getch;
return 0;
}
VUAnswer.com
OUTPUT
VUAnswer.com
REGARD SARIM
WHATSAPP +923162965677
PLEASE NOTE:
Don't copy-paste the same answer.
Make sure you can make some changes to your solution file
before submitting copy paste solution will be marked zero.
If you found any mistake then correct yourself and inform me.
Before submitting an assignment check your assignment
requirement file.
If you need some help and question about file and solutions.