C++ in Xcode Pass the values by reference to complete the programming tasks. Usi
ID: 3799450 • Letter: C
Question
C++ in Xcode
Pass the values by reference to complete the programming tasks.
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.
(Place snipping photo below.)
Explanation / Answer
#include <iostream>
using namespace std;
void convertToYen(int n)
{
cout<<"The amount in yen is "<<n*112.8<<endl;
}
void convertToEuro(int n)
{
cout<<"The amount in euro is "<<n*0.94<<endl;
}
void convertToPeso(int n)
{
cout<<"The amount in peso is "<<n*19.93<<endl;
}
void convertToAll(int n)
{
cout<<"The amount in yen is "<<n*112.8<<endl;
cout<<"The amount in euro is "<<n*0.94<<endl;
cout<<"The amount in peso is "<<n*19.93<<endl;
}
int main()
{
int op,n;
while(true)
{
cout<<"List of options:"<<endl;
cout<<"1) Convert to yen"<<endl;
cout<<"2) Convert to Euro"<<endl;
cout<<"3) Convert to Peso"<<endl;
cout<<"4) Convert to all three of them"<<endl;
cout<<"Select one of the 4 options:";
cin>>op;
if(op>4)
{
cout<<"Invalid option."<<endl;
continue;
}
if(op<=0)
{
break;
}
cout<<"Enter the amount in dollars:$";
cin>>n;
if(op==1)
{
convertToYen(n);
}
else if(op==2)
{
convertToEuro(n);
}
else if(op==3)
{
convertToPeso(n);
}
else
{
convertToAll(n);
}
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.