Create a program that will convert peso value into 5 different currency using functions. Let the user input the peso value and select a specific currency based on the menu.
#include <iostream>
using namespace std;
void Menu()
{
cout << "\nPlease, select some of the following:"
<< "\nE - Convert to Euro"
<< "\nD - Convert to Dollar"
<< "\nI - Indian Rupee"
<< "\nJ - Japanese yen"
<< "\nP - Pound Sterling"
<<"\n0 - Exit program";
cout << "\nYour select:";
}
double ConvertEuro(double peso) { return peso*0.0459;}
double ConvertDollar(double peso) { return peso*0.0504;}
double ConvertRupee(double peso) { return peso*3.7998; }
double ConvertYen(double peso) { return peso*6.1966; }
double ConvertPound(double peso) { return peso*0.03839; }
int main()
{
double peso;
char select;
do
{
cout << "Please, enter a number of pesos: ";
cin >> peso;
Menu();
cin >> select;
switch (select)
{
case 'E':case 'e':
{
cout << ConvertEuro(peso)<<" Euro";
break;
}
case 'D':case 'd':
{
cout << ConvertDollar(peso) << " Dollar";
break;
}
case 'I':case 'i':
{
cout << ConvertRupee(peso) << " Rupee";
break;
}
case 'J':case 'j':
{
cout << ConvertYen(peso) << " Yen";
break;
}
case 'P':case 'p':
{
cout << ConvertPound(peso) << " Pound";
break;
}
}
cout << endl;
} while (select != '0');
}
Comments
Leave a comment