-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmoney-conversion-using-switch.cpp
More file actions
105 lines (83 loc) · 2.22 KB
/
Copy pathmoney-conversion-using-switch.cpp
File metadata and controls
105 lines (83 loc) · 2.22 KB
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
#include <iostream>
#include <cstring>
void pound_conversion(char convert_to,double quantity)
{
const double pound_to_yen = 152.12;
const double pound_to_euro = 1.1866;
switch(convert_to)
{
case'Y':
std::cout << pound_to_yen * quantity << std::endl;
break;
case'E':
std::cout << pound_to_euro * quantity << std::endl;
break;
default:
std::cout << "Unrecognized symbol " << convert_to << std::endl;
break;
}
}
void euro_conversion(char convert_to,double quantity)
{
const double euro_to_pound = 0.8411;
const double euro_to_yen = 129.04;
switch(convert_to)
{
case'Y':
std::cout << euro_to_yen * quantity << std::endl;
break;
case'P':
std::cout << euro_to_pound * quantity << std::endl;
break;
default:
std::cout << "Unrecognized symbol " << convert_to << std::endl;
break;
}
}
void yen_conversion(char convert_to,double quantity)
{
const double yen_to_euro = 0.0078;
const double yen_to_pound = 0.0066;
switch(convert_to)
{
case'E':
std::cout << yen_to_euro * quantity << std::endl;
break;
case'P':
std::cout << yen_to_pound * quantity << std::endl;
break;
default:
std::cout << "Unrecognized symbol for converting to " << convert_to << std::endl;
break;
}
}
int main()
{
char convert_from = ' ';
char convert_to = ' ';
double quantity = 0.0;
std::cout << "This is a Money conversion program the following currencies are available for conversion" << std::endl;
std::cout << "Y for Yenn ,P for Pound and E for Euro" << std::endl;
std::cout << "Please enter the currency to convet from" << std::endl;
std::cin >> convert_from;
std::cout << "Please enter the currency to convet to" << std::endl;
std::cin >> convert_to;
std::cout << "Please enter the quantity to be converted" << std::endl;
std::cin >> quantity;
std::cout << convert_from << " " << convert_to << std::endl;
switch(convert_from)
{
case'Y':
yen_conversion(convert_to,quantity);
break;
case'P':
pound_conversion(convert_to,quantity);
break;
case'E':
euro_conversion(convert_to,quantity);
break;
default:
std::cout << "Unrecognized symbol to convert from " << convert_from << std::endl;
break;
}
}