Tuesday, August 5, 2025

CURRENCY CONVERTER IN C++

#include <iostream>

 using namespace std;
 class currency{
    float Amount;
int choice;
    public:
currency(float c  ){
    Amount=c;
    cout<<" the money in your account is "<<Amount<<endl;
    if(Amount<0){
cout<<"invalid amount entered"<<endl;
exit(0);
}
}

void selection(){
    cout<<" select your currency "<<endl;
    cout<<" available currencies are -: \n 1.Dollar\n 2.rupee\n 3.pound\n4.Dinar\n5.Dirham\n ";
    cin>>choice;
    if(choice==1){
        cout<<" you have "<<Amount<<" dollars "<<endl;
        DOLLAR();
    }
    if(choice==2){
        cout<<" you have "<<Amount<<" rupees "<<endl;
        RUPEES();
    }
    if(choice==3){
        cout<<" you have "<<Amount<<" pounds "<<endl;
        POUNDS();
    }
    if(choice==4){
        cout<<" you have "<<Amount<<" dinars "<<endl;
        DINARS();
    }
    if(choice==5){
        cout<<" you have "<<Amount<<" darahim "<<endl;
        DIRHAM();
    }
}
void DOLLAR(){
    int a;
    cout<<" select currency to convert into \n1.Rupees\n2.Pounds\n3.Dinar\n4.Dirham\n";
    cin>>a;
    if(a==1){
        cout<<" you have "<<Amount*87.81<<" rupees "<<endl;
    }
    if(a==2){
        cout<<" you have "<<Amount*0.75<<" pounds "<<endl;
    }
    if(a==3){
        cout<<" you have "<<Amount*0.306<<" dinar "<<endl;
    }
if(a==4){
        cout<<" you have "<<Amount*3.67<<" dirham "<<endl;
    }
}
void RUPEES(){
    int b;
    cout<<" select currency to convert into \n1.Dollar\n2.Pounds\n3.Dinar\n4.Dirham\n";
    cin>>b;
    if(b==1){
        cout<<" you have "<<Amount*0.011<<" dollars "<<endl;
    }
    if(b==2){
        cout<<" you have "<<Amount*0.0086<<" pounds "<<endl;
    }
    if(b==3){
        cout<<" you have "<<Amount*0.0035<<" dinar "<<endl;
    }
if(b==4){
        cout<<" you have "<<Amount*0.042<<" dirham "<<endl;
    }
}
void POUNDS(){
    int c;
    cout<<" select currency to convert into \n1.Dollars\n2.Rupees\n3.Dinar\n4.Dirham\n";
    cin>>c;
    if(c==1){
        cout<<" you have "<<Amount*1.33<<" dollars "<<endl;
    }
    if(c==2){
        cout<<" you have "<<Amount*116.82<<" rupees "<<endl;
    }
    if(c==3){
        cout<<" you have "<<Amount*0.41<<" dinar "<<endl;
    }
if(c==4){
        cout<<" you have "<<Amount*4.88<<" dirham "<<endl;
    }
}
void DINARS(){
    int d;
    cout<<" select currency to convert into \n1.Dollars\n2.Rupees\n3.Pounds\n4.Dirham\n";
    cin>>d;
    if(d==1){
        cout<<" you have "<<Amount*3.27<<" dollars "<<endl;
    }
    if(d==2){
        cout<<" you have "<<Amount*287.29<<" rupees "<<endl;
    }
    if(d==3){
        cout<<" you have "<<Amount*2.46<<" pounds "<<endl;
    }
if(d==4){
        cout<<" you have "<<Amount*12.02<<" dirham "<<endl;
    }}
void  DIRHAM(){
    int e;
    cout<<" select currency to convert into \n1.Dollar\n2.Rupees\n3.Pounds\n4.Dinar\n";
    cin>>e;
    if(e==1){
        cout<<" you have "<<Amount*0.27<<" dollar "<<endl;
    }
    if(e==2){
        cout<<" you have "<<Amount*23.91<<" rupees "<<endl;
    }
    if(e==3){
        cout<<" you have "<<Amount*0.20<<" pounds "<<endl;
    }
if(e==4){
        cout<<" you have "<<Amount*0.083<<" dirham "<<endl;
    }
}
 };
 int main() {
    currency A(5);
    A.selection();

 return 0;
 
 }

No comments:

Post a Comment

list in c#

  using System ; using System . Collections . Generic ; class Program {     static void Main () {         // Write your C# code here  ...