-
Notifications
You must be signed in to change notification settings - Fork 1
/
forex_trading.cxx
208 lines (168 loc) · 3.92 KB
/
forex_trading.cxx
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#include<iostream>
#include<string>
#include<sstream>
using namespace std;
void printTrade();
void bookTrade();
void userChoice();
void exit();
long USD2INR(long x) // function declaration
{
long finalamount, amount;
finalamount=66*x;
return(finalamount);
}
double INR2USD(double x)
{
double finalamount, amount,y;
finalamount=0.0153*x;
return(finalamount);
}
int EURO2USD()
{
cout<<"\n To be filled in by the user \n";
}
int USD2EURO()
{
cout<<"\n To be filled in by the user \n";
}
class Forex
{
private:
int useroptions;
int amount[30];
string name[30];
char curr_pair[30];
char reply1;
char reply2;
double finalamount;
public:
int currencyPair(int[]) // function declaration
{
int finalamount[30]; // function prototyping
int i;
int amount[30];
while(i<3)
finalamount[i]=66*amount[30];
return(finalamount[i]);
}
void bookTrade()
{
int i=0;
int finalamount;
while(i<3)
{ //while begins
//int i;
//char name[30];
cout<<"\n Whats your name? \n";
cin>>name[i];
cout<<"\n Enter currency pair \n ";
cin>>curr_pair;
cout<<"\n Enter the amount of money you wanna transfer \n";
cin>>amount[i];
cout<<"\n Amount you have entered is \n"<<amount[i]<<"\n";
currencyPair(amount[i]);// function calling
finalamount=currencyPair(amount[i]);
************************************************************************************
// Part of the program that I am editing
cout<<"enter conversion system \n Enter 1 for USD2INR \n Enter 2 for INR2USD \n Enter 3 for EURO2USD \n Enter 4 for USD2EURO \n ";
cin>>curr;
switch(curr)
{
case 1:// USD2INR(amount);
finalamount=USD2INR(amount);
cout<<" \n Final amount after USD2INR is "<<finalamount<<"\n";
break;
case 2: //INR2USD(amount);
finalamount=INR2USD(amount);
cout<<" \n Final amount after INR2USD is "<<finalamount<<"\n";
break;
case 3: EURO2USD();
break;
case 4:USD2EURO();
break;
default: cout<<"\n Invalid input \n ";
break;
}
if(curr==1)
{
cout<<" \n Final amount after USD2INR is "<<finalamount<<"\n";
}
else if(curr==2)
{
cout<<" \n Final amount after INR2USD is "<<finalamount<<"\n";
}
return 0;
}
*************************************************************************************
cout<<"\n Final value after currency conversion is "<<finalamount<<"\n";
cout<<"\n Do you wanna book this trade? \n";
cout<<"\n Enter capital Y for yes and capital N for no \n";
cin>>reply1;
if(reply1=='Y')
{ // first if begins here
cout<<"\n Trade with John fixed for final amount of"<<finalamount<<"\n Sure you wanna continue? \n ";
cout<<"\n Enter capital Y for yes and capital N for no \n";
cin>>reply2;
{ // safe parenthesis begins here
if(reply2=='Y')
{ // second if begins here
cout<<"\n Amount "<<finalamount<<" transferred to "<<name[i]<<" \n Thanks for trading!! "<<"\n";
} // second if ends here
else if(reply2=='N')
{ // else if begins here
cout<<"\n Trade cancelled at second chance !! \n ";
userChoice();
} // else if ends here
} // safe parenthesis ends here
}// first if ends here
else if(reply1=='N')
{
cout<<"\n Trade cancelled at first chance \n ";
userChoice();
} // else if ends here
i++;
} // while ends
//return 0;
userChoice();
}// int main ends here // function bookTrade() ends here
void printTrade()
{
int n,i;
for(n=0;n<3;n++)
{
cout<<"\n Customer name is "<<name[n]<<"\n"<<" Amount is "<<amount[n]<<"\n Final amount is "<<finalamount[n]<<"\n";
}
userChoice();
}
void exit()
{
cout<<"\n How you gonna exit ? is the question\n";
}
void userChoice()
{
cout<<"\n Enter what you wanna do \n 1) Book Trade \n 2) Print Trades \n 3) Exit \n \n";
cin>>useroptions;
//while(1)
//{//while(1) begins
switch(useroptions)
{
case 1: bookTrade();
break;
case 2: printTrade();
break;
case 3: exit();
break;
default: cout<<"\n Wrong input, buddy !! \n";
//break;
//void flushCin();
}
//} // while(1) ends here
}// function userChoice definition ends here
}; // class ends here
int main()
{
Forex forex1;
forex1.userChoice();
return 0;
}