-
Notifications
You must be signed in to change notification settings - Fork 0
/
conversion.cpp
87 lines (83 loc) · 1.43 KB
/
conversion.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include <iostream>
using namespace std;
class rs
{
public:
float rs;
virtual void conv() = 0;
void disp()
{
cout << "is eqvivalent to " << rs << " INR\n\n";
}
};
class doll : public rs
{
float dol;
public:
void conv()
{
cout << "Enter currncy in dollar : ";
cin >> dol;
rs = 54.3 * dol;
cout <<dol << " in dollar ";
disp();
}
};
class euro : public rs
{
float er;
public:
void conv()
{
cout << "Enter currency in Euro : ";
cin >> er;
rs = 70.2 * er;
cout <<er << " in euro ";
disp();
}
};
class pound : public rs
{
float pnd;
public:
void conv()
{
cout << "Enter currency in pound : ";
cin >> pnd;
rs = 81.1 * pnd;
cout <<pnd << " in pound ";
disp();
}
};
int main()
{
int choice;
doll d;
euro e;
pound p;
cout << "\tCurrency conversion\n";
while (1)
{
cout << "1-$ to Rs 2-Euro to Rs 3-Pound to Rs 4-Exit\n";
cout<<"Enter your choice : ";
cin>>choice;
switch (choice)
{
case 1:
d.conv();
break;
case 2:
e.conv();
break;
case 3:
p.conv();
break;
case 4:
exit(0);
break;
default:
cout << "Enter a valid choice\n\n";
}
}
return 0;
}