A simple program to convert the philippine peso to us dollar currency vice versa using a C++ programming language.
I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you. My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com. My mobile number here in the Philippines is 09173084360.Please subscribe to my channel https://www.youtube.com/channel/UCOs-lpOoIeJoh6gpJthPoGgThank you very much for your support.
Program Listing
// Jake R. Pomperada, MAED-IT, MIT
// February 18, 2022
#include <iostream>
class CurrencyConverter
{
public:
explicit CurrencyConverter(float rate) : exchangeRate(rate)
{
}
float convertDollarToPeso(float amount)
{
return amount * exchangeRate;
}
float convertPesoToDollar(float amount)
{
return amount / exchangeRate;
}
private:
float exchangeRate;
};
int main()
{
int choice;
float pesoValue, amount, result = 0.00;
std::cout << "\n\n";
std::cout << "US Dollar To Philippine Peso Vice Versa in C++\n\n";
std::cout << "USD 1 is equivalent to Php ";
std::cin >> pesoValue;
std::cout << "\nPress 1 for PESO to DOLLAR conversion\nPress 2 for DOLLAR to PESO conversion\n";
while(1)
{
std::cout << "\nChoice: ";
std::cin >> choice;
std::cin.ignore(255, '\n');
if(choice != 1 && choice != 2)
{
std::cerr << "Invalid choice\n";
return 0;
}
std::cout << "Amount: ";
std::cin >> amount;
std::cin.ignore(255, '\n');
CurrencyConverter cc(pesoValue);
if( choice == 1)
{
result = cc.convertPesoToDollar(amount);
std::cout << amount << " Peso" << " = " << result << " US Dollar\n";
}
else if (choice == 2)
{
result = cc.convertDollarToPeso(amount);
std::cout << amount << " Dollar" << " = " << result << " Philippine Peso\n";
}
}
}