Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions