Learn how to code a simple currency converter in C++

Are you looking for a project to practice your programming skills in C++? This tutorial will show you how to write a C++ program that converts currency.

Steps

  1. 1
    Download Microsoft Visual Studio. Go to visualstudio.microsoft.com and download the Community version of Visual Studio to start writing your C++ Currency Converter.
  2. 2
    Open up Visual Studio and create a project.
    Advertisement
  3. 3
    Add a .cpp in your source files to start coding.
  4. 4
    Declare your libraries and namespace. To make sure everything run, we must use include for consio.h, cstdlib, fstream, iomanip, iostream and string.
    #include <consio.h>
    #include <cstdlib>;
    #include <fstream>;
    #include <iomanip>;
    #include <iostream>;
    #include <string>;
    using namespace std;
    
  5. 5
    Create the main function where you are going to write the code in. Write all the codes inside the main function.
     int main()
    {
    
    }
    
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
    Prompt user input. Use cout and cin statement to prompt the user for information.
    cout << cout << setw(COLMFT1) << left << "Enter a value (US dollars): ";
        cin >> usd;
        cout << endl;
    
  11. 11
  12. 12
    Show the conversion rate of currency on screen. Ex: $1 USD = $0.85 Euro
    cout << setw(COLMFT1) << left << "Conversion rate(per US dollar): ";
    cout << setw(COLMFT1) << right << rate << endl;
    


  13. 13
  14. 14
    Show the converted currency.
  15. 15
    Add a closing statement to the application. Use cout statement to add a closing to the application.
    cout << "\n--------------------------- " << endl;
    cout << "\nEnd of Rate Converter" << endl;
    
  16. 16
    Run the Windows debugger to make sure the application is running correctly. Click on “Local Windows Debugger” or Press F5 on the keyboard to run the application.


  17. Advertisement

About This Article

wikiHow is a “wiki,” similar to Wikipedia, which means that many of our articles are co-written by multiple authors. To create this article, volunteer authors worked to edit and improve it over time. This article has been viewed 21,509 times.
How helpful is this?
Co-authors: 6
Updated: May 27, 2022
Views: 21,509
Categories: Programming
Advertisement