-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathq05.cpp
58 lines (51 loc) · 1.59 KB
/
q05.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
/*
/* Design, develop, and execute a program in C++ based on the
/* following requirements:
/* An EMPLOYEE class is to contain the following data members and
/* member functions:
/* Data members: Employee_Number (an integer), Employee_Name (a
/* string of characters), Basic_Salary (an integer) , All_Allowances
/* (an integer), IT (an integer), Net_Salary (an integer).
/* Member functions: to read the data of an employee, to calculate
/* Net_Salary and to print the values of all the data members.
/* (All_Allowances = 123% of Basic; Income Tax (IT) = 30% of the
/* gross salary (= basic_Salary _ All_Allowance); Net_Salary =
/* Basic_Salary + All_Allowances – IT)
/*
*/
#include <iostream>
using namespace std;
class Employee {
int number, basic_salary, all_allowances, it, net_salary;
char name[20];
public:
Employee() {
cout << endl << " Enter the employee number: ";
cin >> number;
cout << " Enter the employee name: ";
cin >> name;
cout << " Enter the Basic Salary: ";
cin >> basic_salary;
}
void calculate() {
all_allowances = 1.23 * basic_salary;
int gross_salary = basic_salary + all_allowances;
it = 0.3 * gross_salary;
net_salary = basic_salary + all_allowances - it;
}
void display() {
cout << endl << " Number: " << number;
cout << endl << " Name: " << name;
cout << endl << " Basic Salary: " << basic_salary;
cout << endl << " All Allowances: " << all_allowances;
cout << endl << " Income Tax: " << it;
cout << endl << " Net Salary: " << net_salary << endl;
}
};
int main() {
Employee emp;
emp.calculate();
emp.display();
return 0;
}