60 377
Assignments Done
98,1%
Successfully Done
In April 2018

Answer to Question #48325 in C++ for anu

Question #48325
1. An EMPLOYEE class contains the following members:
Data members: employee_number, employee_name, basic pay, allowance, income tax, net salary
Member functions: to read the data, to calculate net salary and to print data members
Write a C++ program to read the data of 5 employees and compute the net salary of each employee given that the allowance is 20% of the basic pay and income tax is 30% of the gross salary (basic pay+allowance)
Expert's answer
#include <stdlib.h>
#include <iostream>  
#include <stdio.h>
#include <cstdlib> 
#include <string>
using namespace std;
class Employee
{
private:
int employeeNumber;
string employeeName;
float basicPay;
float allowance;
float incomeTax;
float netSalary;
public:
Employee() 
{
employeeNumber = 0;
employeeName = ""; basicPay = 0;
allowance= 0; incomeTax = 0;  netSalary = 0;
}
void ReadData(int _employeNumber)
{
employeeNumber = _employeNumber;
system("cls");
cout<<"Enter the name : ";
cin>>employeeName;
cout<<"Enter the basic pay : ";
cin>>basicPay;
}
void CalculateNetSalary()
{
allowance =  0.2 * basicPay;
incomeTax = 0.3 * (allowance + basicPay);
netSalary = basicPay + allowance - incomeTax;
}
void DisplayInformation()
{
cout<<"-----------------------------------------------"<<endl;
cout<<"Employe Number : "<<employeeNumber<<endl;;
cout<<"Name           : "<<employeeName<<endl;;
cout<<"Basic Pay      : "<<basicPay<<endl;;
cout<<"Allowance      : "<<allowance<<endl;;
cout<<"Income Tax     : "<<incomeTax<<endl;;
cout<<"Net Salary     : "<<netSalary<<endl;;
cout<<"-----------------------------------------------"<<endl;
}

};
int main()
{
Employee mas[5];
for (int i = 0; i < 5; i ++)
{
mas[i].ReadData(i+1);
mas[i].CalculateNetSalary();
}
system("cls");
for (int i = 0; i < 5; i ++)
mas[i].DisplayInformation();
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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions