-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcurrencycon.cpp
144 lines (119 loc) · 4.82 KB
/
currencycon.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#include<iostream>
using namespace std;
class currcon{
private:
double usdtoeuroRate;
double eurotousdRate;
double indrupeetousdRate;
double usdtoindrupeeRate;
double yuantousdRate;
double usdtoyuanRate;
public:
currcon(double usdtoeuro,double eurotousd,double indrupeetousd,double usdtoindrupee,double yuantousd,double usdtoyuan){
usdtoeuroRate=usdtoeuro;
eurotousdRate=eurotousd;
indrupeetousdRate=indrupeetousd;
usdtoindrupeeRate=usdtoindrupee;
yuantousdRate=yuantousd;
usdtoyuanRate=usdtoyuan;
}
void showexchangerate() const{
cout<<"---------- Current Exchange Rate ----------"<<endl;
cout<<"1 usd to euro:"<<usdtoeuroRate<<endl;
cout<<"1 euro to usd:"<<eurotousdRate<<endl;
cout<<"1 indian rupee to usd:"<<indrupeetousdRate<<endl;
cout<<"1 usd to indian rupee:"<<usdtoindrupeeRate<<endl;
cout<<"1 chinese yuan to usd:"<<yuantousdRate<<endl;
cout<<"1 usd to chinese yuan:"<<usdtoyuanRate<<endl;
cout<<"\n\n";
}
double usdtoeuro(double usdamo){
return usdamo*usdtoeuroRate;
}
double eurotousd(double euroamo){
return euroamo*eurotousdRate;
}
double indrupeetousd(double indamo){
return indamo*indrupeetousdRate;
}
double usdtoindrupee(double usdamo){
return usdamo*usdtoindrupeeRate;
}
double yuantousd(double yuanamo){
return yuanamo*yuantousdRate;
}
double usdtoyuan(double usdamo){
return usdamo*usdtoyuanRate;
}
};
int main(){
const double initialusdtoeuroRate=0.91;
const double initialeurotuusdRate=1.10;
const double initialindRupeetousdRate=0.012;
const double initialusdtoindRupeeRate=83.87;
const double initialyuantousdRate=0.14;
const double initialusdtoyuanRate=7.16;
currcon converter(initialusdtoeuroRate,initialeurotuusdRate,initialindRupeetousdRate,initialusdtoindRupeeRate,initialyuantousdRate,initialusdtoyuanRate);
int choice;
double amount;
char ch;
do{
system("cls");
converter.showexchangerate();
cout<<"-----< Currency Converter >-----"<<endl;
cout<<"1.convert usd into euro"<<endl;
cout<<"2.convert euro into usd"<<endl;
cout<<"3.convert indian rupees into usd"<<endl;
cout<<"4.convert usd into indian rupees"<<endl;
cout<<"5.convert chinese yuan into usd"<<endl;
cout<<"6.convert usd into chinese yuan"<<endl;
cout<<"7.Exit"<<endl;
cout<<"Enter a choice:";
cin>>choice;
switch(choice){
case 1:
cout<<"Enter a amount:";
cin>>amount;
cout<<amount<<" "<<"usd is equivalent to"<<" "<<converter.usdtoeuro(amount)<<" "<<"euro"<<endl;
system("pause");
break;
case 2:
cout<<"Enter a amount:";
cin>>amount;
cout<<amount<<" "<<"euro is equivalent to"<<" "<<converter.eurotousd(amount)<<endl<<"usd"<<endl;
system("pause");
break;
case 3:
cout<<"Enter a amount:";
cin>>amount;
cout<<amount<<" "<<" indian rupee is equivalent to"<<" "<<converter.indrupeetousd(amount)<<" "<<"usd"<<endl;
system("pause");
break;
case 4:
cout<<"Enter a amount:";
cin>>amount;
cout<<amount<<" "<<"usd is equivalent to"<<" "<<converter.usdtoindrupee(amount)<<" "<<endl;
system("pause");
break;
case 5:
cout<<"Enter a amount:";
cin>>amount;
cout<<amount<<" "<<" chinese yuan equivalent to"<<" "<<converter.yuantousd(amount)<<endl;
system("pause");
break;
case 6:
cout<<"Enter a amount:";
cin>>amount;
cout<<amount<<" "<<"usd is equivalent to"<<" "<<converter.usdtoyuan(amount)<<endl;
system("pause");
break;
case 7:
exit(0);
break;
default:
cout<<"please enter a valid choice";
break;
}
}while(choice!=0);
return 0;
}