#include<iostream.h>
#include<conio.h>
class employee
{
private:
int sno,basic_salary,da,hra,it,lic,deductions,n_salary;
char name[25];
public:
void get_details();
void put_data();
};
void employee::get_details()
{
cout<<"enter sno";
cout<<"Enter name and net salary of employee";
cin>>sno>>name>>n_salary;
}
void employee::put_data()
{
da=0.8*n_salary;
hra=0.6*n_salary;
it=0.2*n_salary;
deductions=da+hra+it;
basic_salary=n_salary+deductions;
cout<<sno;
cout<<"\t"<<name;
cout<<"\t"<<n_salary<<"\t"<<deductions<<"\t"<<basic_salary<<"\n";
}
void main()
{
clrscr();
employee e[5];
int n;
cout<<"enter n";
cin>>n;
for(int i=1;i<=n;i++)
{
e[i].get_details();
}
clrscr();
cout<<"Sno\tname\tnetsalary\tdeductions\tbasic\n";
for(i=1;i<=n;i++)
{
e[i].put_data();
cout<<endl;
}
getch();
}
Sunday, 7 December 2014
C++ program to print the salary details of an employee
Posted by Madan
Posted on 14:03





