Answer to Question #269362 in C++ for Moh

Question #269362

write a program that uses a class employee to display employee details. The class should include the following members.

Data members: Empno, Empname, basic pay, house allowances ,medical allowances.

Member function: to read employee details to calculate gross salary and not net salary.

Calculate gross salary and net salary.

Gross salary= baasic +house allowances+medical allowances

Net salay=Gross salary - tax


1
Expert's answer
2021-11-21T04:57:36-0500
#include <windows.h>
#include <iostream>


using namespace std;


class employee
{
	int   Empno;
	char  Empname[20];
	float basic_pay;
	float house_allowances;
	float medical_allowances;
	float employee_net_salary;
	float employee_gross_salary;


	public:


		void get_emp_details();
		float find_net_salary(float basic, float house_allowances, float medical_allowances);
		float find_gross_salary(float basic, float house_allowances, float medical_allowances);
		void show_emp_details();
};


void employee :: get_emp_details()
{
	cout<<"\nEnter Employee number: ";
	cin>>Empno;
	cout<<"\nEnter Employee name: ";
	cin>>Empname;
	cout<<"\nEnter employee basic pay: ";
	cin>>basic_pay;
	cout<<"\nEnter employee House allowances: ";
	cin>>house_allowances;
	cout<<"\nEnter employee medical allowances: ";
	cin>>medical_allowances;
}


float employee :: find_net_salary(float basic, float house_allowances, float medical_allowances)
{
    return (basic_pay+house_allowances)-medical_allowances;
}
float employee :: find_gross_salary(float basic_pay, float house_allowances, float medical_allowances)
{
    return (basic_pay+house_allowances+medical_allowances);
}


void employee :: show_emp_details()
{
	cout<<"\n\n**** Details of  Employee ****";
	cout<<"\nEmployee Name                   :  "<<Empname;
	cout<<"\nEmployee number                 :  "<<Empno;
	cout<<"\nBasic pay                       :  "<<basic_pay;
	cout<<"\nEmployee house allowance        :  "<<house_allowances;
	cout<<"\nIncome Tax                      :  "<<medical_allowances;
	cout<<"\nNet Salary                      :  "<<find_net_salary(basic_pay, house_allowances, medical_allowances);
	cout<<"\nGross Salary                    :  "<<find_gross_salary(basic_pay, house_allowances, medical_allowances);
	cout<<"\n-------------------------------\n";
}




int main()
{
    employee emp;
    
    emp.get_emp_details();
    emp.show_emp_details();


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS