C++: Currency Converter (US Dollars to British Pounds, Euros, Japanese Yen, Chinese Yuan, and Indian Rupees)

by matt392 in Circuits > Software

7 Views, 0 Favorites, 0 Comments

C++: Currency Converter (US Dollars to British Pounds, Euros, Japanese Yen, Chinese Yuan, and Indian Rupees)

currencyconverter2.png

Currency converter in C++, using exchange rates from late September, 2023. Converts US Dollars to British Pounds, Euros, Japanese Yen, Chinese Yuan, and Indian Rupees.

// Currency converter

#include <iostream>
#include <string>

using namespace std;

int main()

{ // start main function

double FirstUsCurrency;
double SecondUsCurrency;
double ThirdUsCurrency;
double TotalUsCurrency;
double TotalBritshPounds;
double TotalEuros;
double TotalYen;
double TotalYuan;
double TotalRupees;

cout << "The name of the student that wrote this program is Matt R.\n";

cout << "Enter the 1st US currency amount: ";
cin >> FirstUsCurrency;

cout << "Enter the 2nd US currency amount: ";
cin >> SecondUsCurrency;

cout << "Enter the 3rd US currency amount: ";
cin >> ThirdUsCurrency;

TotalUsCurrency = FirstUsCurrency + SecondUsCurrency + ThirdUsCurrency;

cout << "The total currency in US dollars is: $";
cout << TotalUsCurrency << endl;
cout << "---------------------\n";
cout << "Converting US dollars to British Pounds.\n";
cout << "1 US dollar is .80 British Pounds.\n";
TotalBritshPounds = TotalUsCurrency * .8;
// char(156)
cout << "The total US dollars converted to British Pounds is: " << char(156) << TotalBritshPounds;
cout << endl;
cout << "---------------------\n";
cout << "Converting US dollars to Euros\n";
cout << "1 US dollar is .93 Euros.\n";
TotalEuros = TotalUsCurrency * .93;
cout << "The total US dollars converted to Euros is: " << TotalEuros << " Euros";
cout << endl;
cout << "---------------------\n";
cout << "Converting US dollars to Japanese Yen\n";
cout << "1 US dollar is 147.78 Yen.\n";
TotalYen = TotalUsCurrency * 147.78;
cout << "The total US dollars converted to Yen is: " << char(157) << TotalYen;
cout << endl;
cout << "---------------------\n";
cout << "Converting US dollars to Chinese Yuan\n";
cout << "1 US dollar is 7.27 Yuan.\n";
TotalYuan = TotalUsCurrency * 7.27;
cout << "The total US dollars converted to Yuan is: " << char(157) << TotalYuan;
cout << endl;
cout << "---------------------\n";
cout << "Converting US dollars to Indian Rupees\n";
cout << "1 US dollar is 83.09 Indian Rupees.\n";
TotalRupees = TotalUsCurrency * 83.09;
cout << "The total US dollars converted to Rupess is: " << TotalRupees;
cout << endl;

return 0;

} // end main function

Supplies

codeblockslogo.png
desktopcomputer.jpg
c++image.jpg
  1. Computer or laptop.
  2. Code::Blocks IDE for C++ programming.

currencyconverter3.jpg

Currency converter in C++, using exchange rates from late September, 2023. Converts US Dollars to British Pounds, Euros, Japanese Yen, Chinese Yuan, and Indian Rupees.

// Currency converter

#include <iostream>
#include <string>

using namespace std;

int main()

{ // start main function

double FirstUsCurrency;
double SecondUsCurrency;
double ThirdUsCurrency;
double TotalUsCurrency;
double TotalBritshPounds;
double TotalEuros;
double TotalYen;
double TotalYuan;
double TotalRupees;

cout << "The name of the student that wrote this program is Matt R.\n";

cout << "Enter the 1st US currency amount: ";
cin >> FirstUsCurrency;

cout << "Enter the 2nd US currency amount: ";
cin >> SecondUsCurrency;

cout << "Enter the 3rd US currency amount: ";
cin >> ThirdUsCurrency;

TotalUsCurrency = FirstUsCurrency + SecondUsCurrency + ThirdUsCurrency;

cout << "The total currency in US dollars is: $";
cout << TotalUsCurrency << endl;
cout << "---------------------\n";
cout << "Converting US dollars to British Pounds.\n";
cout << "1 US dollar is .80 British Pounds.\n";
TotalBritshPounds = TotalUsCurrency * .8;
// char(156)
cout << "The total US dollars converted to British Pounds is: " << char(156) << TotalBritshPounds;
cout << endl;
cout << "---------------------\n";
cout << "Converting US dollars to Euros\n";
cout << "1 US dollar is .93 Euros.\n";
TotalEuros = TotalUsCurrency * .93;
cout << "The total US dollars converted to Euros is: " << TotalEuros << " Euros";
cout << endl;
cout << "---------------------\n";
cout << "Converting US dollars to Japanese Yen\n";
cout << "1 US dollar is 147.78 Yen.\n";
TotalYen = TotalUsCurrency * 147.78;
cout << "The total US dollars converted to Yen is: " << char(157) << TotalYen;
cout << endl;
cout << "---------------------\n";
cout << "Converting US dollars to Chinese Yuan\n";
cout << "1 US dollar is 7.27 Yuan.\n";
TotalYuan = TotalUsCurrency * 7.27;
cout << "The total US dollars converted to Yuan is: " << char(157) << TotalYuan;
cout << endl;
cout << "---------------------\n";
cout << "Converting US dollars to Indian Rupees\n";
cout << "1 US dollar is 83.09 Indian Rupees.\n";
TotalRupees = TotalUsCurrency * 83.09;
cout << "The total US dollars converted to Rupess is: " << TotalRupees;
cout << endl;

return 0;

} // end main function