change this code to do the same purpose and same output :
C++ , change this code to do the same purpose and same output :
Source Code:
#include <iostream>
using namespace std;
void convert_from_AED(float amt, int to) {
float prices[10] = {3.653000,
4.250930,
4.958710,
0.230970,
0.049350,
0.074380,
2.662350,
2.757670,
0.032880,
0.022950};
amt = amt / prices[to];
cout << "\n\nConverted Amount is: " << amt;
}
void convert_to_AED(float amt, int from) {
float prices[10] = {3.685000,
4.533530,
5.293750,
0.236360,
0.050920,
0.076750,
2.810320,
2.957860,
0.034570,
0.023780};
amt = amt * prices[from];
cout << "\n\nConverted Amount is: " << amt;
}
int main()
{
int choice, curr;
float amt;
cout << "\n\nFOREIGN EXCHANGE\n================";
cout << "\n\n1. Convert currency from AED \n"
<< "2. Convert currency to AED \n"
<< "Enter Choice number: ";
cin >> choice;
cout << "\n\n0. USD - US Dollar \n"
<< "1. EUR - Euro \n"
<< "2. GBP - British Pound \n"
<< "3. EGP - Egyptian Pound \n"
<< "4. INR - Indian Rupee \n"
<< "5. PHP - Philippine Peso \n"
<< "6. SGD - Singapore Dollar \n"
<< "7. AUD - Australian Dollar \n"
<< "8. JPY - Japan Yen \n"
<< "9. PKR - Pakistan Rupee \n"
<< "Enter Choice number: ";
cin >> curr;
cout << "\n\nEnter Amount: \n";
cin >> amt;
switch(choice) {
case 1: convert_from_AED(amt, curr);
break;
case 2: convert_from_AED(amt, curr);
break;
default: break;
}
}
Step by step
Solved in 2 steps with 1 images