-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvertmoney.cpp
160 lines (129 loc) · 4.57 KB
/
convertmoney.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/* Engineer: {user}
Assignment: Programming Assignment 3
Date: 3-1-18
Description: This program will input American money and convert it to foreign currency
*/
#include <iostream>
#include <iomanip>
using namespace std;
// This program will input American money and convert it to foreign currency
// Prototypes of the functions
void convertMulti(float dollars, float& euros, float& pesos);
void convertMulti(float dollars, float& euros, float& pesos, float& yen);
float convertToYen(float dollars);
float convertToEuros(float dollars);
float convertToPesos(float dollars);
const float EURO_EXCHANGE = 1.06;
const float PESO_EXCHANGE = 9.73;
const float YEN_EXCHANGE = 124.35;
int main()
{
float dollars;
float euros;
float pesos;
float yen;
cout << fixed << showpoint << setprecision(2);
cout << "Please input the amount of American Dollars you want converted "
<< endl;
cout << "to euros and pesos" << endl;
cin >> dollars;
convertMulti(dollars, euros, pesos);
cout << "Please input the amount of American Dollars you want converted\n";
cout << " to euros, pesos and yen" << endl;
cin >> dollars;
convertMulti(dollars, euros, pesos, yen);
cout << "Please input the amount of American Dollars you want converted\n";
cout << " to yen" << endl;
cin >> dollars;
yen = convertToYen(dollars);
cout << "$" << dollars << " was converted to " << yen << " yen." << endl;
cout << "Please input the amount of American Dollars you want converted\n";
cout << " to euros" << endl;
cin >> dollars;
euros = convertToEuros (dollars);
cout << "$" << dollars << " was converted to " << euros << " euros." << endl;
cout << "Please input the amount of American Dollars you want converted\n";
cout << " to pesos " << endl;
cin >> dollars;
pesos = convertToPesos(dollars);
cout << "$" << dollars << " was converted to " << pesos << " pesos." << endl;
return 0;
}
// All of the functions are stubs that just serve to test the functions
// Replace with code that will cause the functions to execute properly
// **************************************************************************
// convertMulti
//
// task: This function takes a dollar value and converts it to euros
// and pesos
// data in: dollars
// data out: euros and pesos
//
// *************************************************************************
void convertMulti(float dollars, float& euros, float& pesos)
{
euros = dollars * EURO_EXCHANGE;
cout << "$" << dollars << " was converted to " << euros << " euros." << endl;
pesos = dollars * PESO_EXCHANGE;
cout << "$" << dollars << " was converted to " << pesos << " pesos." << endl;
}
// ************************************************************************
// convertMulti
//
// task: This function takes a dollar value and converts it to euros
// pesos and yen
// data in: dollars
// data out: euros pesos yen
//
// ***********************************************************************
void convertMulti(float dollars, float& euros, float& pesos, float& yen)
{
euros = dollars * EURO_EXCHANGE;
cout << "$" << dollars << " was converted to " << euros << " euros." << endl;
pesos = dollars * PESO_EXCHANGE;
cout << "$" << dollars << " was converted to " << pesos << " pesos." << endl;
yen = dollars * YEN_EXCHANGE;
cout << "$" << dollars << " was converted to " << yen << " yen." << endl;
}
// ****************************************************************************
// convertToYen
//
// task: This function takes a dollar value and converts it to yen
// data in: dollars
// data returned: yen
//
// ***************************************************************************
float convertToYen(float dollars)
{
float yen;
yen = dollars * YEN_EXCHANGE;
return yen;
}
// ****************************************************************************
// convertToEuros
//
// task: This function takes a dollar value and converts it to euros
// data in: dollars
// data returned: euros
//
// ****************************************************************************
float convertToEuros(float dollars)
{
float euros;
euros = dollars * EURO_EXCHANGE;
return euros;
}
// *****************************************************************************
// convertToPesos
//
// task: This function takes a dollar value and converts it to pesos
// data in: dollars
// data returned: pesos
//
// ****************************************************************************
float convertToPesos(float dollars)
{
float pesos;
pesos = dollars * PESO_EXCHANGE;
return pesos;
}