-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathq16.cpp
36 lines (31 loc) · 809 Bytes
/
q16.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
/* WAP to calculate gross salary of an employee by demonstrating the concept of
* nesting of member functions */
#include <iostream>
using namespace std;
class Employee {
public:
float basic, hra, dearness, gross;
int enter_salary();
float gross_salary();
};
int Employee::enter_salary() {
cout << "Enter basic salary: ";
cin >> basic;
cout << "Enter HRA: ";
cin >> hra;
cout << "Enter dearness allowance: ";
cin >> dearness;
return 0;
}
float Employee::gross_salary() {
enter_salary();
gross = basic + hra + dearness;
return gross;
}
int main() {
Employee emp;
emp.gross_salary();
cout << "-------------------------------------------" << endl;
cout << "Gross salary of employee: " << emp.gross <<endl;
return 0;
}