-
Notifications
You must be signed in to change notification settings - Fork 0
/
5_3.cpp
58 lines (54 loc) · 973 Bytes
/
5_3.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
#include "iostream"
using namespace std;
class currency
{
int rupee, paisa;
public:
void enter();
void show();
currency sum(currency);
void add(currency, currency);
};
void currency::enter()
{
cout << "enter rupee : ";
cin >> rupee;
cout << "enter paisa : ";
cin >> paisa;
}
void currency::show()
{
if (paisa >= 100)
{
rupee = rupee + paisa / 100;
paisa = paisa % 100;
}
cout << rupee << "." << paisa << endl;
}
currency currency::sum(currency c)
{
currency ca;
rupee = c.rupee + rupee;
paisa = c.paisa + paisa;
return ca;
}
void currency::add(currency c1, currency c2)
{
rupee = c1.rupee + c2.rupee;
paisa = c1.paisa + c2.paisa;
}
int main()
{
currency c1, c2, c3, c4;
c1.enter();
// c1.show();
cout << "enter for c2";
c2.enter();
// c2.show();
// cout << "c3";
c3 = c2.sum(c1);
c3.show();
c4.add(c1, c2);
c4.show();
return 0;
}