Answer to Question #324678 in C++ for deni

Question #324678

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.

1
Expert's answer
2022-04-06T10:14:41-0400
#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');
}



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS