Question
C++ program starting code: /* Allows currency to be converted from various types to US dollars. Author: Jill Courte for CSE 153 Spring, 2016 */
C++ program
starting code:
/*
Allows currency to be converted from various types to US dollars.
Author: Jill Courte for CSE 153 Spring, 2016
*/
#include
#include
using namespace std;
const int USD = 0;
const int EUR = 1;
const int GBP = 2;
const int INR = 3;
const int AUD = 4;
const int CAD = 5;
const int ZAR = 6;
const int NZD = 7;
const int JPY = 8;
//Outputs a menu of currency types for user, returning a constant value
// as defined above representing the selected currency.
int getUserSelection ()
{
int selection;
cout
cout
cout
cout
cout
cout
cout
cout
cout
cout
cin >> selection;
return selection;
}
//Converts the numeric type to a String representation.
//Use this to output a String representation of the type.
string convertTypeToString(int type)
{
switch (type)
{
case USD:
return "US Dollars";
case EUR:
return "Euros";
case GBP:
return "Great Britan Pounds";
case INR:
return "Indian Rupees";
case AUD:
return "Australian Dollars";
case CAD:
return "Canadian Dollars";
case ZAR:
return "South African Rands";
case NZD:
return "New Zealand Dollars";
case JPY:
return "Japanese Zen";
}
return "";
}
int main(int argc, char *argv[])
{
int userSelection = getUserSelection();
string selectionAsAString = convertTypeToString(userSelection);
cout
cin.ignore();
cin.get();
}
Complete a program that allows a user to select a currency to be converted to US dollars. Your program should loop, use the code given to display a menu of conversion types and get a user selection, then input an amount of the selected currency, convert it to US dollars, and output the result. Use this conversion chart to get the conversion factors for each type of currency: AUD Auto-refresh 15x 0:38 USD EUR 1 USD 1.00000 0.92072 Inverse: 1.00000 1.08611 1 EUR 1.086111.00000 Inverse: 0.92072 1.00000 1 GBP 1.44476 1.33022 Inverse: 0.69215 0.75176 Mid-market rates: 2018-01-12 22:03 UTC 1 GBP INR 0.6921566.8904 1.44476 0.01495 0.75176 72.6504 1.33022 0.01376 1.00000 96.6409 1.00000 0.01035 1.43135 0.69864 1.55460 0.64325 2.06796 0.48357 . CAD ZAR NZD JPY 1.42628 16.6697 1.52973 117.675 0.70112 0.059990.65371 0.00850 1.54910 18.1051 1.66145 127.808 0.64554 0.05523 0.60188 0.00782 2.06064 24.0837 221009170.013 0.485290.04152 0.45247 0.00588 You have been given code that includes two functions for you to use (we'll learn more about functions in the next module). Here is the main function that shows using the code you have been provided. int main(int argc, char *argv[]) int user Selection = getUserSelection(); string selectionAsString = convertTypeToString(user Selection); coutStep 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