Write a program to calculate the net salary of an employee using the concept of structure.
#include<iostream>
using namespace std;
struct Salary
{
float basic, da,hra,ta,others;
float pf,it;
float net_salary;
};
int main()
{
Salary s;
cout<<"Please, enter Basic Salary($): ";
cin>>s.basic;
cout<<"Please, enter HRA($): ";
cin>>s.hra;
cout<<"Please, enter TA($): ";
cin>>s.ta;
cout<<"Please, enter others($): ";
cin>>s.others;
//calculate DA 12% of Basic Salary
s.da=s.basic*0.12;
//calculate pf 14% of Basic Salary
s.pf=s.basic*0.14;
//calculate pf 15% of Basic Salary
s.it=s.basic*0.15;
s.net_salary=s.basic+s.da+s.hra+s.ta+s.others-(s.pf+s.it);
cout<<"Net salary is "<<s.net_salary;3
}
Comments
Leave a comment