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.

Completed code using if/else operation.

(8 points) for successful execution of code be sure to include snips of your results

(2 points) for consistent/appropriate style

(2 points) for 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

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

More Books

Students also viewed these Databases questions

Question

How is communication defi ned?

Answered: 1 week ago

Question

QUESTION 4 A variable must be declared before its use. True False

Answered: 1 week ago

Question

Find the derivative. f(x) 8 3 4 mix X O 4 x32 4 x32 3 -4x - x2

Answered: 1 week ago