Sample output: Feel free to use an IDE to complete the following task. Using mul
ID: 3783660 • Letter: S
Question
Sample output:
Feel free to use an IDE to complete the following task. Using multiple functions and receiving user input. In your main function use a switch case to create a menu for the user. create a program that converts user input in Dollars to Euro, Yen, or Peso. Prompt the user to enter amount. If user input is less than or equal to zero prompt the user and stop the program. Create 4 Functions: 1) Converts and outputs conversion in Yen 2) Converts and outputs conversion in Euro 3) Converts and outputs conversion in Peso 4) Converts and outputs all 3 currencies. Update the program to accept user input for dollar amount to be converted. Attach Snipping photos of all 4 methods being executed.
Explanation / Answer
//Rate conversion program
#include<iostream>
#include<cstdlib> //for exit function
using namespace std;
//function prototypes
float dollar_to_yen(int dollar);
float dollar_to_euro(int dollar);
float dollar_to_peso(int dollar);
int main()
{
int menu,amount;
float yen, euro, peso;
cout<<"Please enter $ amount:"<<endl;
cin>>amount;
cout<<"Main Menu:"<<endl;
cout<<"Enter # to run program or quit:"<<endl;
cout<<"1) Yen Conversion"<<endl;
cout<<"2) Euro Conversion"<<endl;
cout<<"3) Peso Conversion"<<endl;
cout<<"4) All Currencies"<<endl;
cout<<"5) Quit"<<endl;
cin>>menu;
switch(menu)
{
case 1:
yen = dollar_to_yen(amount);
cout<<"You have "<<yen<<" Yen"<<endl;
break;
case 2:
euro = dollar_to_euro(amount);
cout<<"You have "<<euro<<" Euros"<<endl;
break;
case 3:
peso = dollar_to_peso(amount);
cout<<"You have "<<peso<<" Peso"<<endl;
break;
case 4:
yen = dollar_to_yen(amount);
cout<<"You have "<<yen<<" Yen"<<endl;
euro = dollar_to_euro(amount);
cout<<"You have "<<euro<<" Euros"<<endl;
peso = dollar_to_peso(amount);
cout<<"You have "<<peso<<" Peso"<<endl;
break;
case 5:
exit(1);
default:
cout<<"Wrong choice";
}//end of switch case
return 0;
}//end of main function
float dollar_to_yen(int dollar)
{
return 113.26*dollar;
}
float dollar_to_euro(int dollar)
{
return 0.93*dollar;
}
float dollar_to_peso(int dollar)
{
return dollar*21.03;
}
Hope it helps.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.