Answer to Question #175235 in C++ for Hari bashkar

Question #175235

The class employee comprises of employee details such as emp_id(integer type), employee name(character array type) ,basic salary(float type), allowance(float type) and PF(float type). Get three employee details using getemployee() method and use display() method to calculate and display the net salary(basic salary+allowance+PF) of employees.


1
Expert's answer
2021-03-24T14:08:11-0400
#include <iostream>


using namespace std;


class employee
{
private:
	//emp_id(integer type), employee name(character array type)
	int   id;
	char  name[15];
	//basic salary(float type), allowance(float type) and PF(float type).
	float basic_salary;
	float allowance;
	float PF;
public:
	//Get three employee details using getemployee() method
	void getemployee(){
			cout<<"Enter employee id: ";
			cin>>id;
			cout<<"Enter employee name: ";
			cin>>name;
			cout<<"Enter employee basic salary: ";
			cin>>basic_salary;
			cout<<"Enter employee allowance: ";
			cin>>allowance;
			cout<<"Enter employee PF: ";
			cin>>PF;
	}
	void display(){
		 //calculate and display the net salary(basic salary+allowance+PF) of employees.
		float net_salary=basic_salary+allowance+PF;
		cout<<"\nThe net salary: "<< net_salary<<"\n";
	}
};
int main(){
	employee empl;
	empl.getemployee();
	empl.display();
	system("pause");
	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