Write a program that would print the information (nume, 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
Roma. 1994. 64C, Jaipur
Ramya. 2000. 68D-Udaipur
Teena. 1999. 26B-Kota
#include<iostream>
using namespace std;
class Employee{
public:
string name;
int year;
int salary;
int address;
void getDetails(){
for(int i=1;i<=3;i++){
cout<<"\nStudent "<<i<<" details"<<endl;
cout<<"Enter the name of the student: ";
cin>>name;
cout<<"Enter the year you joined: ";
cin>>year;
cout<<"Enter the salary: ";
cin>>salary;
cout<<"Enter the address: "<<endl;
cin>>address;}
}
void display(){
for(int i=1;i<=3;i++){
cout<<"Displaying student "<<i<<" details"<<endl;
cout<<name<<", "<<year<<", "<<address<<endl;
}
}
};
int main()
{
Employee E;
E.getDetails();
E.display();
}
Comments
Leave a comment