Ad Code

CS304 Assignment No 03 Fall 2022 100% Correct Solution

 CS304 Assignment No 03 Fall 2022 100% Correct Solution

Dont Copy past ke change always

further detail fill contact us form



#include <iostream>

#include <conio.h>

using namespace std;

class person

{

private:

int age;

string name;

string gender;

string address;

string phone;

public:

person()

{

age=0;

name="";

gender="";

address="";

phone="";

}

void setAge()

{

cout<<"\n Enter age:";

cin>>age;

}

void setName()

{

cout<<"\n Enter name:";

cin>>name;

}

void setGender()

{

cout<<"\n Enter gender:";

cin>>gender;

}

void setAddress()

{

cout<<"\n Enter address:";

cin>>address;

}

void setPhone()

{

cout<<"\n Enter phone number:";

cin>>phone;

}

int getAge()

{

return age;

}

string getName()

{

return name;

}

string getGender()

{

return gender;

}

string getAddress()

{

return address;

}

string getPhone()

{

return phone;

}

void Save_Information()

{

setName();

setGender();

setAge();

setAddress();

setPhone();

}

void Display_Information()

{

cout<<"Name:"<<getName()<<endl;

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

{

cout<<"\n Enter Qualification:";

cin>>qualification;

}

void setSalary()

{

cout<<"\n Enter Salary:";

cin>>salary;

}

string getQualification()

{

return qualification;

}

float getSalary()

{

return salary;

}

void Save_Information()

{

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;

string previousEducation;

public:

student()

{

totalMarks=0.0;

obtainedMarks=0.0;

previousEducation="";

}

void setTotalMarks()

{

cout<<"\n Enter Total Marks:";

cin>>totalMarks;

}

void setObtainedMarks()

{

cout<<"\n Enter Obtained Marks:";

cin>>obtainedMarks;

}

void setPreviousEducation()

{

cout<<"\n Enter Previous Education:";

cin>>previousEducation;

}

float getTotalMarks()

{

return totalMarks;

}

float getObtainedMarks()

{

return obtainedMarks;

}

string getPreviousEducation()

{

return previousEducation;

}

void Save_Information()

{

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;

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

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

cout<<"Display Student Information:"<<endl<<endl;

cout<<"----------------------------"<<endl;

for(int p=0; p<y; p++)

S[p]->Display_Information();

}

getch;

return 0;

}

Post a Comment

0 Comments

Close Menu