Currency Converter (Using Function)

Pages: 12
Hi, can someone make a C++ program of Currency Converter using function which takes a value from user and convert it into (Rupees,Dollar,Pound) the format of function should be like this
void my_Currency_converter(amount,current_currency,new_currency,currency_exchance_Rate)
eg, my_Currency_converter(50,R,P,150)



Please help, as my exam is next week and I need all the help I could get.
Well then maybe you should get started, what have you done so far?
Have practiced loops (while, for), Conditional Statements etc.. Kinda finding difficulty with problems related to Functions, Arrays, Multi Dimensional Arrays, passing arrays to functions, using characters in arrays/functions , matrix multiplication etc. That's all the part of the syllabus tho .
Well, there is tons of content on google and youtube explaining exactly how functions, arrays, 2D arrays, passing arrays to functions and everything else you said works. So go look for it and start implementing. Break down your project into pieces and atleast get started with anything.

If you get stuck on a specific thing feel free to post your code and ask a question, we'll help out.
yeah, I will thanks.

And I posted the above program because it was in our last quiz and I totally messed it up..
Anyone please help me with this program?

At least tell me the way how to approach it.
If this is an assignment could you post it?
You should get started by referencing the math behind the conversions, start with what you know and don't get confused by the parts that are more difficult. You may also use only floats to make your life a little bit easier.. Use "if" statements to check the currencies..
Hey so I tried making the program myself, but It has some problem and giving me some errors, can someone make it perfect for me?

#include<iostream>
using namespace std;
void my_Currency_converter(float , char , char , float );
int main()
{
float amount, rupee, pound, dollar;
char current_currency, new_currency;
float currency_exchange_Rate;

cout<<"Enter value"<<endl;
cin>>amount;
cout<<"enter R, P, or D"<<endl;
cin>>current_currency;
cout<<"enter output R, P, or D"<<endl;
cin>>new_currency;

if(current_currency=='R')
{
switch(new_currency)
{
case'P':
{
currency_exchange_Rate=150;
break;
}

case'D':
{
currency_exchange_Rate=100;
break;
}
}
}
else if(current_currency=='P')
{
switch(new_currency)
{
case'R':
{
currency_exchange_Rate=1/100;
break;
}

case'D':
{
currency_exchange_Rate=15/11;
break;
}
}
}
else if(current_currency=='D')
{
switch(new_currency)
{
case'R':
{
currency_exchange_Rate=1/150;
break;
}

case'P':
{
currency_exchange_Rate=11/15;
break;
}
}

my_Currency_converter(amount,current_currency,new_currency,currency_exchange_Rate);
}

void my_Currency_converter(float val, char cur, char new, float rate)
{
val=val*rate;
cout<<val<<endl;
}
Help me guys!!

I have exam next week ^_^ and Im freaking out ..!!
If you were really bothered about getting help with this problem, you'd make an effort to do the things that would make it more likely that people would help you, such as:

- using code tags to make your code readable (http://www.cplusplus.com/articles/z13hAqkS/)
- actually telling us what the problem is, rather than lazy, meaningless nonsense like "It has some problem and giving me some errors"

Should we, therefore, conclude that you're not really that interested in getting answers?
If I knew what the problem is why would I be posting in here ? anyway, thanks for your help, I'll fix that program up myself .
If I knew what the problem is why would I be posting in here ?

If you have no clue what the problem was, that means you didn't try to compile it, since compiling it would result in a compiler error that you could, perhaps, share with the folks who might like to help you. But, if you can't even be bothered to attempt to compile your own code...
No I have complied and tried to run it and its giving me errors that I'm not able to figure out. Lemme try to copy paste the errors here.

C:\Users\Salahuddin\Documents\New Folder 3\Currency Convertor.cpp In function 'int main()':
71 54 C:\Users\Salahuddin\Documents\New Folder 3\Currency Convertor.cpp [Error] expected ',' or '...' before 'new'
72 1 C:\Users\Salahuddin\Documents\New Folder 3\Currency Convertor.cpp [Error] a function-definition is not allowed here before '{' token
75 1 C:\Users\Salahuddin\Documents\New Folder 3\Currency Convertor.cpp [Error] expected '}' at end of input
Ok managed to get rid of the last error i.e expected '}' at the end of the input one, now these errors still remain.

C:\Users\Salahuddin\Documents\New Folder 3\Currency Convertor.cpp In function 'int main()':
71 54 C:\Users\Salahuddin\Documents\New Folder 3\Currency Convertor.cpp [Error] expected ',' or '...' before 'new'
72 1 C:\Users\Salahuddin\Documents\New Folder 3\Currency Convertor.cpp [Error] a function-definition is not allowed here before '{' token



"new" is a reserved C++ keyword. You can't use it as a variable name.

Why are you passing 4 parameters into my_Currency_converter when the function only uses two of them?

Because in the question format it's asking me to pass 4 parameters, I managed to make and run this program passing 3 parameters tho, here it is..


//(Rupees,Dollar,Pound) the format of function should be like this
//void my_Currency_converter(val,x,y)
//eg, my_Currency_converter(50,R,P,150)


#include<iostream>
using namespace std;
void my_Currency_converter(float,char,char);

main()
{
float val;
char x,y;
cout<<"Please enter a value"<<endl;
cin>>val;
cout<<"Please choose your current currency \n 1.Rupees \n 2.Dollar \n 3.Pounds "<<endl;
cin>>x;
cout<<"Please choose the currency you wanna convert it into \n 1.Rupees \n 2.Dollar \n 3.Pounds "<<endl;
cin>>y;
my_Currency_converter(val,x,y);

}

void my_Currency_converter (float val,char x,char y)
{
if (x=='1')
{
if(y=='1')
{
cout<<"Your new currency is"<<val<<endl;
}
if(y=='2')
{
cout<<"Your new currency is"<<val/100<<endl;
}
if(y=='3')
{
cout<<"Your new currency is"<<val/150<<endl;
}

}
if(x=='2')
{
if(y=='1')
{
cout<<"Your new currency is"<<val*100<<endl;
}
if(y=='2')
{
cout<<"Your new currency is"<<val<<endl;
}
if(y=='3')
{
cout<<"Your new currency is"<<val*0.5<<endl;
}
}
if(x=='3')
{
if(y=='1')
{
cout<<"Your new currency is"<<val/150<<endl;
}
if(y=='2')
{
cout<<"Your new currency is"<<val*1.5<<endl;
}
if(y=='3')
{
cout<<"Your new currency is"<<val<<endl;
}
}



}




I'm not sure how to pass the Exchange rate in it ??
Um... the exchange rate was one of the two parameters you were actually using. Why did you remove it?
Because its not working, the other program where you only need to tell your current and new currency and the exchange rate is mentioned in the cout , works without any program .
Pages: 12