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

Using derived classes, implement the following hierarchy (from Commentary Notes)

ID: 3824191 • Letter: U

Question

Using derived classes, implement the following hierarchy (from Commentary Notes):

person

employee

dependent

manager

worker

Maintain the following information for each object:

person: name, date of birth, gender, SSN, address, phone number

employee: hire date, salary location, phone number

dependent: SSN of employee of which this person is a dependent, address (if different from associated employee's)

manager: title

worker: project on which the worker works

Provide the ability to input and output all the information about each type of object. Also provide public member functions to 1) inquire the value of all the above items, and 2) change the ones that are reasonably changeable.

Below is my code, but I am able to get and display the value of the parent only. Please correct my code..

My code:

Result which I get:

/Users/nandinirajeswaran/CLionProjects/Module6/cmake-build-debug/Module6
warning: this program uses gets(), which is unsafe.
Student
Enter data
Name: Nanindi
Date of Birth: 240890
Gender: f
SSN: 23432435
Address: 34jhkjhk
Phone: 749202744

Displaying data
Name: Nanindi
Date of Birth(mmddyyyy): 240890
Gender: f
SSN: 23432435
Address: 34jhkjhk
Phone Number: 749202744

Employee
Enter data
Name: Date of Birth: nandini
Gender: SSN: Address: Phone: Hire date: Salary: Location: Phone Number:
Displaying data
Name:
Date of Birth(mmddyyyy): 0
Gender:
SSN:
Address:
Phone Number: 0
Hired Date 0
Salary: 0
Location: nandini
Phone Number: 0

Dependent
Enter data
Name:

Please help me..

Explanation / Answer

class dependent: public person
{
char Address[200];
int SSN;
public:
void getdata()
{
person::getdata();
cout<<"SSN of the employee: ";
cin>>SSN;
cout<<"Address:";
cin>>Address;
}
void display()
{
person::display();
cout<<"SSN of the employee: "<<SSN<<endl;
cout<<"Address:"<<Address<<endl;
}
};

class manager: public person
{
char title[100];
public:
void getdata()
{
person::getdata();
cout<<"Title: ";
cin>>title;
}
void display()
{
person::display();
cout<<"Title of the manager "<<title<<endl;

}
};

class project: public person
{
char project[100];
public:
void getdata()
{
person::getdata();
cout<<"Project: ";
cin>>project;
}
void display()
{
person::display();
cout<<"Project Name: "<<project<<endl;

}
};

int main()
{

  

employee e;
dependent d;
manager m;
project p;
  cout<<"Student"<<endl;
cout<<"Enter data"<<endl;
s.getdata();
cout<<endl<<"Displaying data"<<endl;
s.display();
cout<<endl<<"Employee"<<endl;
cout<<"Enter data"<<endl;
e.getdata();
cout<<endl<<"Displaying data"<<endl;
e.display();
cout<<endl<<"Dependent"<<endl;
cout<<"Enter data"<<endl;
d.getdata();
cout<<endl<<"Displaying data"<<endl;
d.display();
cout<<endl<<"Manager"<<endl;
cout<<"Enter data"<<endl;
m.getdata();
cout<<endl<<"Displaying data"<<endl;
m.display();
cout<<endl<<"Project"<<endl;
cout<<"Enter data"<<endl;
p.getdata();
cout<<endl<<"Displaying data"<<endl;
p.display();
  
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote