The following are the assumed existing equivalent currency rates corresponding to the US dollar ($1.00); Australia (Aus $), 1.09; Hong Kong (HK $), 7.81; Indonesia (Rupiah), 990.41; Japan (Yen), 234.93; Malaysia (Ringgit), 2.34; Philippines (Peso), 13.80. Prepare a program that will accept US dollar and currency to be converted as inputs, then compute the equivalent in the chosen foreign currency. Print the results.
Â
(Use switch statement.)Â
#include<iostream>
using namespace std;
int main()
{
  double dollars;
  int currency;
  cout<<"\nEnter currency dollars to be converted: ";
  cin>>dollars;
  cout<<"\n1. Australia (Aus $)";
cout<<"\n2. Hong Kong(HK $)\n3. Indonesia (Rupiah)";
  cout<<"\n4. Japan (Yen) ";
cout<<"\n5. Malaysia (Ringgit)";
cout<<"\n6. Philippines (Peso)";
  cout<<"\nChoose the currency to be converted to: ";
  cin>>currency;
  Â
  switch(currency){
  case 1:
    cout<<"Equivalence is: Aus $"<<dollars*1.09;
    break;
  case 2:
    cout<<"Equivalence is: HK $"<<dollars*7.81;
    break;
  Â
  case 3:
    cout<<"Equivalence is: Rupiah "<<dollars* 990.41;
    break;
  case 4:
    cout<<"Equivalence is: yen "<<dollars*234.93;
    break;
  Â
  case 5:
    cout<<"Equivalence is: Ringgit "<<dollars*2.34;
    break;
  Â
  case 6:
    cout<<"Equivalence is: Peso "<<dollars*13.80;
    break;
  default:
     cout<<"Invalid choice";
    Â
  }
}
Comments
Leave a comment