You are required to write a program for Currency Exchange rates.The basic idea i
ID: 3618179 • Letter: Y
Question
You are required to write a program for Currency Exchange rates.The basic idea is that user/reader will be able to interchangedifferent currencies using our program. User will have threeoptions i.e. Pakistani Rupees, US Dollars, and Euro.
Detailed Description:
1. The program should display
Please select currencies that you want to exchange.
Description:
Enter ‘R’for Pakistani Rupees.
Enter ‘E’for Euro.
Enter ‘D’for Dollar.
Then your program should take these inputs,
2. Depending upon the choices that userhas entered, your program will further display the prompt
3. Then the program should take two inputsfrom the user as:
-----------------------------------------------------------------
Pleaseselect the currency that you want to convert:
Pleaseselect the currency that you want to convert into:
-----------------------------------------------------------------
4. After getting both inputs, program willcalculate the currency rates on the basis on this information.
1 Euro = 112 Rupees.
1 Dollar = 84 Rupees.
1 Euro = 1.33 Dollars
1 Dollar = 0.75 EUR
After calculating the conversion rate for the selectedcurrencies display it on the screen.
In the end of the program, user should be asked if he/she wantsto make another conversion.
If user presses y then the whole program shouldstart again. If user presses n then the programshould terminate.
Explanation / Answer
//SZ //Currency Exchange Program #include <iostream> using namespace std; /* 1 Euro = 112 Rupees.1 Dollar = 84 Rupees.
1 Euro = 1.33 Dollars
1 Dollar = 0.75 EUR*/
int main() { char myCur, convCur; double myRupees(0), myEuros(0),myDollars(0); double convertedAmount(0); bool flag = false; while(flag == false) { cout << "Welcome to the CurrencyExchange Rate Program!" << endl << endl <<endl; cout << "Key Description " << endl; cout << "R Pakistani Rupees" << endl; cout << "E European Euro" << endl; cout << "D American Dollar" << endl <<endl; while( myCur != 'R' && myCur != 'E'&& myCur != 'D') { cout << "Please select the key forthe currency you have: "; cin >> myCur; myCur = toupper(myCur); if(myCur == 'R' ) { cout <<"Please enter the amount of Rupees you have: "; cin >>myRupees; } else if(myCur == 'E') { cout << " Please enterthe amount of Euros you have: "; cin >> myEuros; } else if(myCur == 'D') { cout << "Please enterthe amount of Dollars you have: "; cin >> myDollars; } else { cout << "Please enter avalid key" << endl; } } do{ cout << "Please select the key for the currency youwant to convert to: "; cin >> convCur; convCur = toupper(convCur); }while(myCur == convCur); if (myCur == 'R' && convCur =='E') { // 1 Euro = 112Rupees. convertedAmount =myRupees / 112; } if (myCur == 'R' && convCur =='D') { //1 Dollar = 84Rupees. convertedAmount =myRupees / 84; } if (myCur == 'E' && convCur =='R') { // 1 Euro = 112 Rupees. convertedAmount = myEuros * 112; } if (myCur == 'E' && convCur =='D') { // 1 Euro = 1.33 Dollars convertedAmount = myEuros * 1.33; } if (myCur == 'D' && convCur =='R') { //1Dollar = 84 Rupees. convertedAmount = myDollars * 84; } if(myCur == 'D' && convCur =='E') { // 1Euro = 1.33 Dollars convertedAmount = myDollars / 1.33; } if(myCur == 'R') { cout <<myRupees << " Rupees converted into "; } if(myCur == 'E') { cout <<myEuros << " Euros converted into "; } if(myCur == 'D') { cout <<myDollars << " Dollars converted into "; } if( convCur == 'R') { cout << convertedAmount<< " Rupees" << endl; } if(convCur == 'E') { cout<< convertedAmount << " Euros" << endl; } if(convCur == 'D') { cout<< convertedAmount << " Dollars" << endl; } char answer; cout << " Would you like to runanother conversion? (y/n)" << endl; cin >> answer; answer = tolower(answer); if (answer == 'n') { flag =true; } system("CLS"); myCur = ''; } system("Pause"); return 0; }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.