Create a structure of Employee that contains following data members

Create a structure of employee that contains

This preview shows page 2 - 3 out of 3 pages.

empSalary() and display(). Create a structure of Employee that contains following data members: o EmployeeNumber, Name, BasicSalary, HouseAllowance, MedicalAllowance,Tax, GrossPay and NetSalary Employeenumber,name and basicsalary must be taken input from the user. empSalary() compute salary with given criteria o HouseAllowence = 10% of BasicSalary o Medical Allowence = 5% of Basic Salary o Tax = 4 % of Basic Salary o GrossSalary = Basic+HouseAllowence+MedicalAllowence o NetSalary = GrossSalary – Tax display() for displaying details of Empolyee #Sample Output Enter the Employee Number :10129 Enter the employee name: Ahmed Ali Enter the Basic Salary: 16500 ************************************* EMPLOYERS SALARY DETAILS ************************************* Employee Number:10129 Employee Name: Ahmed Ali Basic Salary: 16500 House Allowence:1650 Medical Allowence: 825 Gross Salary: 18975 Tax Deduction: 660 Net Salary: 18315 Solution: #include <iostream> #include <string> using namespace std; void empSalary(); //Prototype. void display(); //Prototype. struct Employee { string Name; long int BasicSalary; double HouseAllowance, MedicalAllowance, GrossPay, NetSalary, Tax; int employee_id; }; int main() { cout << "Employee's Information:\n" << endl; cout << "ID: " ;
Image of page 2
cin >> e.employee_id; cout << "Name: " ; cin >> e.Name; cout << "Salary: " ; cin >> e.BasicSalary; empSalary(); display(); } void empSalary() { e.HouseAllowance = e.BasicSalary / 100 * 10; e.MedicalAllowance = e.BasicSalary / 100 * 5; e.GrossPay = e.BasicSalary + e.HouseAllowance + e.MedicalAllowance; e.Tax = e.BasicSalary / 100 * 4; e.NetSalary = e.GrossPay - e.Tax; } void display() { cout << "House Allowance: " << e.HouseAllowance << endl; cout << "Medical Allowance: " << e.MedicalAllowance << endl; cout << "Gross Salary: " << e.GrossPay << endl; cout << "Tax: " << e.Tax << endl; cout << "Net Salary: " << e.NetSalary << endl; }
Image of page 3

You've reached the end of your free preview.

Want to read all 3 pages?

  • Fall '18
  • Zia Ul Rehman

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes