You are on page 1of 16

VISIT ANY MORE FREELY SOLUTIONS

VUAnswer.com

CS304 ASSIGNMENT 3 SOLUTION FALL 2022


Provide by VU Answer

Total Marks: 20
Due Date: 15 Feb 2022

Assignment Submission and Instruction:


Your assignment should be in .CPP format only.

Save your assignment with your ID (e.g., bc000000000.CPP).

CODE Solution:

#include <iostream>
#include <conio.h>
using namespace std;
class person

SUBSCRIBE OUR CHANNEL


https://www.youtube.com/channel/UCvFS8fAv4bvZsOmWu
WMIg3Q

JOIN WHATSAPP GROUP


https://chat.whatsapp.com/CbEPu7qfeNV8v0dZd5yT8J
VISIT ANY MORE FREELY SOLUTIONS

VUAnswer.com
{
private:
int age;
string name;
string gender;
string address;
string phone;
public:
person()
{
age=0;
name="";
gender="";
address="";
phone="";
}
void setAge()
{

SUBSCRIBE OUR CHANNEL


https://www.youtube.com/channel/UCvFS8fAv4bvZsOmWu
WMIg3Q

JOIN WHATSAPP GROUP


https://chat.whatsapp.com/CbEPu7qfeNV8v0dZd5yT8J
VISIT ANY MORE FREELY SOLUTIONS

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;
}

SUBSCRIBE OUR CHANNEL


https://www.youtube.com/channel/UCvFS8fAv4bvZsOmWu
WMIg3Q

JOIN WHATSAPP GROUP


https://chat.whatsapp.com/CbEPu7qfeNV8v0dZd5yT8J
VISIT ANY MORE FREELY SOLUTIONS

VUAnswer.com
void setPhone()
{
cout<<"\nEnter Phone number: ";
cin>>phone;
}
int getAge()
{
return age;
}
string getName()
{
return name;
}
string getGender()
{
return gender;
}
string getAddress()

SUBSCRIBE OUR CHANNEL


https://www.youtube.com/channel/UCvFS8fAv4bvZsOmWu
WMIg3Q

JOIN WHATSAPP GROUP


https://chat.whatsapp.com/CbEPu7qfeNV8v0dZd5yT8J
VISIT ANY MORE FREELY SOLUTIONS

VUAnswer.com
{
return address;
}
string getPhone()
{
return phone;
}
void Save_Information()
{
setName();
setGender();
setAge();
setAddress();
setPhone();
}
void Display_Information()
{
cout<<"Name: "<<getName()<<endl;

SUBSCRIBE OUR CHANNEL


https://www.youtube.com/channel/UCvFS8fAv4bvZsOmWu
WMIg3Q

JOIN WHATSAPP GROUP


https://chat.whatsapp.com/CbEPu7qfeNV8v0dZd5yT8J
VISIT ANY MORE FREELY SOLUTIONS

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()

SUBSCRIBE OUR CHANNEL


https://www.youtube.com/channel/UCvFS8fAv4bvZsOmWu
WMIg3Q

JOIN WHATSAPP GROUP


https://chat.whatsapp.com/CbEPu7qfeNV8v0dZd5yT8J
VISIT ANY MORE FREELY SOLUTIONS

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()

SUBSCRIBE OUR CHANNEL


https://www.youtube.com/channel/UCvFS8fAv4bvZsOmWu
WMIg3Q

JOIN WHATSAPP GROUP


https://chat.whatsapp.com/CbEPu7qfeNV8v0dZd5yT8J
VISIT ANY MORE FREELY SOLUTIONS

VUAnswer.com
{
person::Save_Information();
setQualification();
setSalary();
}
void Display_Information()
{
person::Display_Information();
cout<<"Qualification: "<<getQualification()<<endl;
cout<<"Salary: "<<getSalary()<<endl;
}
};

class Student: public person


{
private:
float totalMarks;
float obtainedMarks;

SUBSCRIBE OUR CHANNEL


https://www.youtube.com/channel/UCvFS8fAv4bvZsOmWu
WMIg3Q

JOIN WHATSAPP GROUP


https://chat.whatsapp.com/CbEPu7qfeNV8v0dZd5yT8J
VISIT ANY MORE FREELY SOLUTIONS

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;
}

SUBSCRIBE OUR CHANNEL


https://www.youtube.com/channel/UCvFS8fAv4bvZsOmWu
WMIg3Q

JOIN WHATSAPP GROUP


https://chat.whatsapp.com/CbEPu7qfeNV8v0dZd5yT8J
VISIT ANY MORE FREELY SOLUTIONS

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()

SUBSCRIBE OUR CHANNEL


https://www.youtube.com/channel/UCvFS8fAv4bvZsOmWu
WMIg3Q

JOIN WHATSAPP GROUP


https://chat.whatsapp.com/CbEPu7qfeNV8v0dZd5yT8J
VISIT ANY MORE FREELY SOLUTIONS

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;

SUBSCRIBE OUR CHANNEL


https://www.youtube.com/channel/UCvFS8fAv4bvZsOmWu
WMIg3Q

JOIN WHATSAPP GROUP


https://chat.whatsapp.com/CbEPu7qfeNV8v0dZd5yT8J
VISIT ANY MORE FREELY SOLUTIONS

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;
}

SUBSCRIBE OUR CHANNEL


https://www.youtube.com/channel/UCvFS8fAv4bvZsOmWu
WMIg3Q

JOIN WHATSAPP GROUP


https://chat.whatsapp.com/CbEPu7qfeNV8v0dZd5yT8J
VISIT ANY MORE FREELY SOLUTIONS

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');

SUBSCRIBE OUR CHANNEL


https://www.youtube.com/channel/UCvFS8fAv4bvZsOmWu
WMIg3Q

JOIN WHATSAPP GROUP


https://chat.whatsapp.com/CbEPu7qfeNV8v0dZd5yT8J
VISIT ANY MORE FREELY SOLUTIONS

VUAnswer.com
cout<<"Display Student Information:"<<endl<<endl;
cout<<"----------------------------"<<endl;
for(int p=0; p<y; p++)
S[p]->Display_Information();
}
getch;
return 0;
}

SUBSCRIBE OUR CHANNEL


https://www.youtube.com/channel/UCvFS8fAv4bvZsOmWu
WMIg3Q

JOIN WHATSAPP GROUP


https://chat.whatsapp.com/CbEPu7qfeNV8v0dZd5yT8J
VISIT ANY MORE FREELY SOLUTIONS

VUAnswer.com

OUTPUT

SUBSCRIBE OUR CHANNEL


https://www.youtube.com/channel/UCvFS8fAv4bvZsOmWu
WMIg3Q

JOIN WHATSAPP GROUP


https://chat.whatsapp.com/CbEPu7qfeNV8v0dZd5yT8J
VISIT ANY MORE FREELY SOLUTIONS

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.

MORE ANY ASSIGNMENTS SOLUTION FREE


VUAnswer.com

SUBSCRIBE OUR CHANNEL


https://www.youtube.com/channel/UCvFS8fAv4bvZsOmWu
WMIg3Q

JOIN WHATSAPP GROUP


https://chat.whatsapp.com/CbEPu7qfeNV8v0dZd5yT8J

You might also like