Question: Copy the provided C++ program to calculate equivalent amount of currency in a number of denominations, using the amount in U.S. Dollars and the desired

Copy the provided C++ program to calculate equivalent amount of currency in a number of denominations, using the amount in U.S. Dollars and the desired equivalent currency as the input.

Currency Exchange

Successful incorporation of two additional currencies, completed code using switch operation.

(4 points) for successful incorporation of additional currencies be sure to include snips of your results

(2 points) for consistent/appropriate style and commenting

// This program performs currency conversion from dollars to // E => euros // P => pesos // S => pounds sterling #include #include using namespace std; int main() { double dollars, equivalentCurr; // variables for dollar amount and equivalent value char currencyCode; // variable for selecting currency const double ECONVERSION{0.7041}, // conversion rate for euros PCONVERSION{11.6325}, // conversion rate for pesos SCONVERSION{0.6144}; // conversion rate for pounds cout << "enter dollar amount" << endl; // Prompt user for dollar value cin >> dollars; // Save the user input to dollars cout << "enter currency code: " // Prompt user for currency input << "E => Euros " "P => Mexican Pesos " "S => British Pounds Sterling " ; cin >> currencyCode; // Save the user input for which currency switch(toupper(currencyCode)) { case 'E': // Calculation to make if euros selected cout << "converting dollars to euros.. "; equivalentCurr = dollars * ECONVERSION; break; case 'P': // Calculation to make if pesos selected cout << "converting dollars to pesos.. "; equivalentCurr = dollars * PCONVERSION; break; case 'S': // Calculation to make if pounds selected cout << "converting dollars to pounds sterling.. "; equivalentCurr = dollars * SCONVERSION; break; default: // Calculation to make if invalid input selected cout << currencyCode << "not supported at this time "; equivalentCurr = dollars; break; } cout << "Equivalent amount: " << equivalentCurr << endl; // Print the result return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!