forked from Nivedpv2004/C-PROGRAMING
-
Notifications
You must be signed in to change notification settings - Fork 0
/
9.cpp
67 lines (65 loc) · 1.23 KB
/
9.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
59
60
61
62
63
64
65
66
67
#include <iostream>
using namespace std;
class engineer{
private:
int salary;
int tax;
public:
engineer(int a)
{
salary = a;
}
void display()
{
cout << "Engineer salary: " << salary << " Income tax: " << tax << endl;
}
friend class incometax;
};
class doctor{
private:
int salary;
int tax;
public:
doctor(int b)
{
salary = b;
}
void display()
{
cout << "Docotrs salary: " << salary << " Income tax: " << tax << endl;
}
friend class incometax;
};
class incometax{
private:
int tax;
public:
void calc(engineer &a)
{
tax = a.salary*0.1;
a.tax = tax;
cout << "Income Tax: " << tax << endl;
}
void calc(doctor &b)
{
tax = b.salary*0.1;
b.tax = tax;
cout << "Income Tax: " << tax << endl;
}
};
int main()
{
incometax qwerty;
int sal_a;
int sal_b;
cout << "Engineers salary: ";
cin >> sal_a;
cout << "Doctors salary: " ;
cin >> sal_b;
engineer eng(sal_a);
doctor doc(sal_b);
qwerty.calc(eng);
qwerty.calc(doc);
eng.display();
doc.display();
}