Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#include #include #include using namespace std; int main ( ) { double Us _ Dollars; string Foreign _ Currency; / / ask how much you
#include
#include
#include
using namespace std;
int main
double UsDollars;
string ForeignCurrency;
ask how much you want
cout "how much currency would you like to convert? ;
cin UsDollars;
giving exampples
cout "whats the abbreviation for the currency you want to convert to endl;
cout "like this" endl;
cout tBRLttBrazilian Real
;
cout tEURttEuro
;
cout tMXNttMexican Peso
endl;
cout "Please use all uppercase for your abbreviations! ;
cin ForeignCurrency;
opening rates file
ifstream inputratestxt;
ifinput.isopen
cout "Cant open rates.txt file";
return ;
string CurrencyType;
double ExchangeRate;
match currency type
bool matched false;
while inputeof && matched
input CurrencyType ExchangeRate;
if CurrencyType ForeignCurrency
matched true;
if matched
const int WIDTH ;
cout left fixed setprecision;
cout setwWIDTHUsDollars" ForeignCurrency endl;
else
cout We cannot covert to that currency yet";
input.close;
return ;
This lab provides more practice with files, stream manipulators, functions, and arrayrelated
tasks.
You shall create a program to process a file of currency exchange transactions from different
foreign currencies to US Dollars. Each line of the "transactions.csv file represents one
exchange transaction using the following format:
currencyabbreviation, currencyname, amount
For example, the following sample "transactions.csv file contains four transactions. The first
one requests to exchange Canadian Dollars to US Dollars. The second one requests to
exchange Brazilian Real to US Dollars. And so on Not all currencies in the
"transactions.csv file have their matching exchange rates in the "rates.txt file.
CAD, Canadian Dollar,
BRLBrazilian Real,
MXN Mexican Peso,
CUP, Cuban Peso,
Your program shall process the transactions and display the results in a nice columned format
using parametric parameters, as illustrated in the following sample output. You don't need to
match the exact number of spaces for each column. But there needs to be digits after the
decimal space for each currency amount.
The following two function prototypes have been created in the "library. file. You are require
to implement these two functions in the "library.cpp file and call these functions in the main
function.
double findratestring abbreviation;
This function is to take the abbreviation of a currency and look up the "rates.txt file to return
the corresponding exchange rate. The function shall return if no matching currency is found.
Note that the "rates.txt file stores the exchange rates from US dollars to different foreign
currencies.
void convertdouble foreign, double rate, double& dollars;
This function is to calculate and store the resulting US dollar amount in the third parameter
using the values of the first two parameters.
When you are ready to submit your work, capture the screenshot of the sample run of your
program. Upload the screenshot to your
Repl.it project. The lab instructor may ask you to
explain your problemsolving process and the code. When evaluating your code on
Repl.it the
lab instructor may modify the content of the "rates.txt and "transactions.csv file.
Librarycpp file
#include
#include
#include
#include
#include "library.h
using namespace std;
double findratestring abbreviation;
double convertdouble amount, string abbreviationfrom, string abbreviationto;
Implement the functions here
double findratestring abbreviation
double rate;
ifabbreviation "USD"
rate ;
else ifabbreviation "EUR"
rate ;
else ifabbreviation BRL
rate ;
else ifabbreviation MXN
rate ;
else ifabbreviation "ARS"
rate ;
else ifabbreviation HKD
rate ;
else ifabbreviation "COP"
rate ;
else ifabbreviation "RUB"
rate ;
else
rate ;
return rate;
libraryh I have so far
#include
using namespace std;
This function takes one parameter as the currency abbreviation. It shall use currency abbreviation to search up the "rates.txt file and return the corresponding exchange rate. If the currency abbreviation does not match any of those in rates.txt the function shall return
double findratestring abbreviation;
This function takes three parameters.
The first one is the amount of US Dollars.
The second one is the exchange rate from US Dollar to a foreign currency.
The third one is the corresponding amount of foreigncurrency that would be determined by the function.
void convertdouble dollars, do
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started