Learn how to code a simple currency converter in C++
X
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.
Learn more...
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
-
1Download Microsoft Visual Studio. Go to visualstudio.microsoft.com and download the Community version of Visual Studio to start writing your C++ Currency Converter.
-
2Open up Visual Studio and create a project.Advertisement
-
3Add a .cpp in your source files to start coding.
-
4Declare 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;
-
5Create the main function where you are going to write the code in. Write all the codes inside the main function.
int main() { }
-
6
-
7
-
8
-
9
-
10Prompt 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
-
12Show 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
-
14Show the converted currency.
-
15Add 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;
-
16Run 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.
Advertisement
About This Article
Advertisement