Question

Write a C++ program to perform currency conversion between dollars, euros, pesos (Mexican) and pounds sterling....

Write a C++ program to perform currency conversion between dollars, euros, pesos (Mexican) and pounds sterling. Use the currency names in your program. The program should accept any user conversion between the four currencies.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<iostream>

using namespace std;

//Function to convert and return currency after conversion
double convert(double currency, double conversionRate)
{
   return currency * conversionRate;
}

int main()
{
   int option;
   double currency1, currency2;
   do
   {
       //Display menu
       cout << " CURRENCY CONVERSION" << endl << endl;
       cout << "1. Dollars to Euros" << endl;
       cout << "2. Dollars to Peso(Mexican)" << endl;
       cout << "3. Dollars to Pounds sterling" << endl;
       cout << "4. Euros to Dollars" << endl;
       cout << "5. Euros to Peso(Mexican)" << endl;
       cout << "6. Euros to Pounds sterling" << endl;
       cout << "7. Peso(Mexican) to Dollars" << endl;
       cout << "8. Peso(Mexican) to Euros" << endl;
       cout << "9. Peso(Mexican) to Pounds sterling" << endl;
       cout << "10. Pounds sterling to Dollars" << endl;
       cout << "11. Pounds sterling to Euros" << endl;
       cout << "12. Pounds sterling to Peso(Mexican)" << endl;
       cout << "13. Exit" << endl << endl;
       cout << "Select your choice: ";
       cin >> option;//Take input from user
       while(option < 0 || option > 13)//Validate option
       {
           cout << "Enter a valid option: ";
           cin >> option;
       }
       cout << endl;
       switch(option)
       {
           case 1:       cout << "Enter amount in Dollars: ";
                       cin >> currency1;
                       currency2 = convert(currency1, 0.87);
                       cout << "Amount in Euros: " << currency2;
                       break;
                      
           case 2:       cout << "Enter amount in Dollars: ";
                       cin >> currency1;
                       currency2 = convert(currency1, 19.13);
                       cout << "Amount in Peso(Mexican): " << currency2;
                       break;
                      
           case 3:       cout << "Enter amount in Dollars: ";
                       cin >> currency1;
                       currency2 = convert(currency1, 0.76);
                       cout << "Amount in Pounds sterling: " << currency2;
                       break;
          
           case 4:       cout << "Enter amount in Euros: ";
                       cin >> currency1;
                       currency2 = convert(currency1, 1.14);
                       cout << "Amount in Dollars: " << currency2;
                       break;          
          
           case 5:       cout << "Enter amount in Euros: ";
                       cin >> currency1;
                       currency2 = convert(currency1, 21.88);
                       cout << "Amount in Peso(Mexican): " << currency2;
                       break;
                      
           case 6:       cout << "Enter amount in Euros: ";
                       cin >> currency1;
                       currency2 = convert(currency1, 0.87);
                       cout << "Amount in Pounds sterling: " << currency2;
                       break;
                      
           case 7:       cout << "Enter amount in Peso(Mexican): ";
                       cin >> currency1;
                       currency2 = convert(currency1, 0.052);
                       cout << "Amount in Dollars: " << currency2;
                       break;
          
           case 8:       cout << "Enter amount in Peso(Mexican): ";
                       cin >> currency1;
                       currency2 = convert(currency1, 0.046);
                       cout << "Amount in Euros: " << currency2;
                       break;
                      
           case 9:       cout << "Enter amount in Peso(Mexican): ";
                       cin >> currency1;
                       currency2 = convert(currency1, 0.04);
                       cout << "Amount in Pounds sterling: " << currency2;
                       break;
                      
           case 10:   cout << "Enter amount in Pounds sterling: ";
                       cin >> currency1;
                       currency2 = convert(currency1, 1.31);
                       cout << "Amount in Dollars: " << currency2;
                       break;  
                      
           case 11:   cout << "Enter amount in Pounds sterling: ";
                       cin >> currency1;
                       currency2 = convert(currency1, 1.15);
                       cout << "Amount in Euros: " << currency2;
                       break;      
                      
           case 12:   cout << "Enter amount in Pounds sterling: ";
                       cin >> currency1;
                       currency2 = convert(currency1, 25.06);
                       cout << "Amount in Peso(Mexican): " << currency2;
                       break;
                      
           case 13:   break;                      
       }
       cout << endl << endl;
   }
   while(option != 13);
   return 0;
}

OUTPUT:

Add a comment
Know the answer?
Add Answer to:
Write a C++ program to perform currency conversion between dollars, euros, pesos (Mexican) and pounds sterling....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • MATLAB Write a program that creates a table showing the conversion from Yen to Pesos. Your...

    MATLAB Write a program that creates a table showing the conversion from Yen to Pesos. Your program should be able to print a user specified number of lines showing the value of the Yen in one column and correlating value of Pesos in the right column. An example of the conversion output follows, with the values of Pesos X’d out: 1 U.S. Dollar ($) = 19.11 Mexican Pesos 1 Japanese Yen (Y) = $0.0091 U.S. Dollar

  • Write a Java that prompts the user like this: “Currency to convert to U.S. dollars: e...

    Write a Java that prompts the user like this: “Currency to convert to U.S. dollars: e = Euros, c= Chinese Yuan, r = Indian Rupees, b = Bitcoin: ”. Then depending on which letter the user enters, the program displays “Amount of Euros/Yuan/Rupees/Bitcoin to convert: ”. (Note: the second prompt should only name the one currency the user asked to convert, not all four currencies.) After the user enters the amount, the program displays “In U.S. dollars, that is $N”,...

  • Write an app using two activities: one activity performs a currency conversion from dollars to another...

    Write an app using two activities: one activity performs a currency conversion from dollars to another currency, and the other activity asks the user to choose which currency to use among five currencies. Include a Model. Include transitions between the two activities. Make the user choice persistent so that next time the user runs the app, his or her previous choice is the default.

  • VII JAVA ASSIGNMENT. Write a program with a graphical interface that allows the user to convert...

    VII JAVA ASSIGNMENT. Write a program with a graphical interface that allows the user to convert an amount of money between U.S. dollars (USD), euros (EUR), and British pounds (GBP). The user interface should have the following elements: a text box to enter the amount to be converted, two combo boxes to allow the user to select the currencies, a button to make the conversion, and a label to show the result. Display a warning if the user does not...

  • Create a currency converter java program. It will store conversion rates between some currency and the...

    Create a currency converter java program. It will store conversion rates between some currency and the US$ for a month. The program flow is as follows: (Part 1)Get user input for the historical data. Historical data will be the currency, day of the month (1-31) and conversion rate. Keep getting input until a null or space is entered for the currency.   Assume 3 currencies max will be entered. Store data in a 2-dimensional array. Maybe 32 rows by 5 columns...

  • please write code in java language and do not add any break, continue or goto statements...

    please write code in java language and do not add any break, continue or goto statements Write a program with a graphical interface that allows the user to convert an amount of money between U.S. dollars (USD), euros (EUR), and British pounds (GBP). The user interface should have the following elements: a text box to enter the amount to be converted, two combo boxes to allow the user to select the currencies, a button to make the conversion, and a...

  • a. Gold Is $350 per ounce In the United States and 2.800 pesos per ounce In Mexico. The nominal exchange rate between U.S. dollar and Mexican pesos that is Implled by the PPP theory Is: pesos. b. Mex...

    a. Gold Is $350 per ounce In the United States and 2.800 pesos per ounce In Mexico. The nominal exchange rate between U.S. dollar and Mexican pesos that is Implled by the PPP theory Is: pesos. b. Mexico experiences Inflation so that the price of gold rises to 4,200 pesos per ounce, whlle the price of gold remalns $350 per ounce In the United States. The nominal exchange rate between U.S. dollars and Mexican pesos that is Implied by the...

  • Write a single C++ program that performs the following conversion (The modulus divide will help you...

    Write a single C++ program that performs the following conversion (The modulus divide will help you get the remainder as shown in class) 39 / 12 = 3 and 39 % 12 = 3, so 3 feet 3 inch(es) Height conversion 1 meter = 39 inches 12 inches = 1 foot Ask/Prompt the user to enter in the height in meters, convert and output the result in feet and inches Example 1 meters as input should produce 3 feet (foot)...

  • Write a program that will convert U.S. dollar amounts to Japanese yen and to euros, storing...

    Write a program that will convert U.S. dollar amounts to Japanese yen and to euros, storing the conversion factors in the constants YEN_PER_DOLLAR and EUROS_PER_ DOLLAR. To get the most up-to-date exchange rates, search the Internet using the term “currency exchange rate”. If you cannot find the most recent exchange rates, use the following: 1 Dollar = 98.93 Yen 1 Dollar = 0.74 Euros Format your currency amounts in fixed-point notation, with two decimal places of precision, and be sure...

  • Using Functions: Conversion Program: Write a program that perform conversions that we use often. Program should...

    Using Functions: Conversion Program: Write a program that perform conversions that we use often. Program should display the following menu                                                             Welcome to the Conversion Program                                                 =============================== Fahrenheit to Celsius Miles to kilometers Liters to Gallons Exit from the program You should implement this program using functions and your program need to have following functions void displayMenu() double fahrenheitToCilsuis(double fTemp) double milesToKilometers(double miles) double litersToGallons(doube liters)

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT