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

Problem: Design an employee class that stores the following members: employee id

ID: 3838123 • Letter: P

Question

Problem: Design an employee class that stores the following members: employee id number Idnum: employee name Name: Salary: employee salary Get employee gets info of the employee Use constructor and destructor, overloading operator and any other methods that you need. Create templates for a dynamic stack that can hold objects of the class described above along with any other data types. The program should have a loop that asks the user if he or she wishes to add or drop an employee. At any stage, user should able to display the stack contents. When the user finishes the program, it should display the final contents of the stack. Test your program for set of 5 names. 2nd Part: Rewrite the above problem for a dynamic queue template and test it.

Explanation / Answer

Below is the code for only Dynamic Stack template

----------------------------------------------------------------------------------

#include <iostream>
#include <stack>
using namespace::std;

class Employee {
public :
int Idnum;
string name;
float salary;

Employee()
{
  
}

Employee(int id, string nm, float sal)
{
Idnum = id;
name = nm;
salary = sal;
}
void Get_employee()
{
cout << "Name : "<<name <<endl<< "ID # : "<<Idnum << endl <<"Salary : "<<salary<<endl<<endl;
}
  
};

int main()
{
int choice,choice1;
stack<Employee> dynstk;
cout <<"1. Satck Processing " << endl <<"2. Queue Processing" << endl <<"Enter your choice : ";
cin >> choice;
int i=0;
while(i==0)
{
cout <<"1. Enter new Employee " << endl <<"2. Delete Employee"<<endl
<<"3. View all Employees"<<endl<<"4. Quit"<< endl <<"Please make a selection : ";
cin >> choice1;
switch(choice1)
{
case 1 :
{
string name1;
int id1;
float salary1;
cout<<"You selected to add employee to stack list"<<endl<<"Please enter below information"<<endl;
cout<<"Name : ";
cin>>name1;
cout<<"ID # : ";
cin>>id1;
cout<<"Salary : ";
cin>>salary1;
Employee emp(id1,name1,salary1);
dynstk.push(emp);
break;
}
case 2:
dynstk.pop();
break;
case 3:
{
stack<Employee> newstk;
while(!dynstk.empty())
{
Employee emp1 = dynstk.top();
emp1.Get_employee();
newstk.push(emp1);
dynstk.pop();
}
while(!newstk.empty())
{
dynstk.push(newstk.top());
newstk.pop();
}
break;
}
case 4:
i=-1;
}
  
}
return 0;
}

Below is the combined code for both Dynamic Stack and Queue templates as per the required output

---------------------------------------------------------------------------------------------------------------------------------------------------------

#include <iostream>
#include <stack>
#include <queue>
using namespace::std;

class Employee {
public :
int Idnum;
string name;
float salary;

Employee()
{
  
}

Employee(int id, string nm, float sal)
{
Idnum = id;
name = nm;
salary = sal;
}
void Get_employee()
{
cout << "Name : "<<name <<endl<< "ID # : "<<Idnum << endl <<"Salary : "<<salary<<endl<<endl;
}
  
};

int main()
{
int choice,choice1;
stack<Employee> dynstk;
queue<Employee> dynque;
cout <<"1. Satck Processing " << endl <<"2. Queue Processing" << endl <<"Enter your choice : ";
cin >> choice;
int i=0;
while(i==0)
{
cout <<"1. Enter new Employee " << endl <<"2. Delete Employee"<<endl
<<"3. View all Employees"<<endl<<"4. Quit"<< endl <<"Please make a selection : ";
cin >> choice1;
switch(choice1)
{
case 1 :
{
string name1;
int id1;
float salary1;
cout<<"You selected to add employee to stack list"<<endl<<"Please enter below information"<<endl;
cout<<"Name : ";
cin>>name1;
cout<<"ID # : ";
cin>>id1;
cout<<"Salary : ";
cin>>salary1;
Employee emp(id1,name1,salary1);
if(choice==1)
dynstk.push(emp);
else
dynque.push(emp);
break;
}
case 2:
if(choice==1)
dynstk.pop();
else
dynque.pop();
break;
case 3:
{
if(choice==1)
{
stack<Employee> newstk;
while(!dynstk.empty())
{
Employee emp1 = dynstk.top();
emp1.Get_employee();
newstk.push(emp1);
dynstk.pop();
}
while(!newstk.empty())
{
dynstk.push(newstk.top());
newstk.pop();
}
}
else
{
queue<Employee> newQ;
while(!dynque.empty())
{
Employee emp1 = dynque.front();
emp1.Get_employee();
newQ.push(emp1);
dynque.pop();
}
dynque=newQ;
}
  
break;
}
case 4:
i=-1;
}
  
}
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