Write a C++ program that would print the information (name, year of joining, salary, address) of three employees by creating a class named 'Employee'. The output should be as follows: Name Year of joining Address Robert 1994 64C- WallsStreat Sam 2000 68D- WallsStreat John 1999 26B- WallsStreat
using namespace std;
/*
Write a C++ program that would print the information (name, year of joining, salary, address) of three employees
by creating a class named 'Employee'. The output should be as follows:
Name Year of joining Address Robert 1994 64C- WallsStreat Sam 2000 68D- WallsStreat John 1999 26B- WallsStreat
*/
#define NO_OF_EMP 3
class Employee
{
public:
string Name;
string JoiningDate;
int Salary;
string AddressLine_1;
string AddressLine_2;
string AddressLine_3;
string Zip;
void GetEmpRec(void)
{
cout<<"\n\nEnter Emp. Name : "; cin>>Name;
cout<<"\nEnter Joining Date : "; cin>>JoiningDate;
cout<<"\nEnter Salary : "; cin>>Salary;
cout<<"\nEnter Address Line-1: "; cin>>AddressLine_1;
cout<<"\nEnter Address Line-2: "; cin>>AddressLine_2;
cout<<"\nEnter Address Line-3: "; cin>>AddressLine_3;
cout<<"\nEnter Zip : "; cin>>Zip;
}
};
main(void)
{
int n;
class Employee E[NO_OF_EMP];
for(n=0;n<NO_OF_EMP;n++)
{
E[n].GetEmpRec();
}
for(n=0;n<NO_OF_EMP;n++)
{
cout<<"\n\nName: "<<E[n].Name<<"\tJoining Date: "<<E[n].JoiningDate<<"\tSalary: "<<E[n].Salary;
cout<<"\n\tAddress: "<<E[n].AddressLine_1<<"\t"<<E[n].AddressLine_2]<<"\t"<<E[n].AddressLine_3;
cout<<"\n\tZip: "<<E[n].Zip;
}
}
Comments
Leave a comment