ive created this currency interest preogram which should calculate the interest depending on the currency amount entered.

if 100 but less than 1000 then 1%, otherwise 3% for all other amounts.

can someone give me any ideas as how to start the interest part of the program off, and which variables i might need to declare in order to caslculate the interest.

ive done the first part where it asks the user for what amount to be converted to which currency.

any help appreciated coding shown below

#include <iostream.h>
int main()
{
int gbp;
int usd;
int euro;
int select = 0;
cout << "Please select from the following: " << endl;
cout << "1) Pounds to US doller" << endl;
cout << "2) Pounds to Euro" << endl << endl;
cout << "Enter: ";
cin >> select;
if (select == 1)
{
cout << " Enter amount in Pounds to convert to Dollers: ";
cin >> gbp;
usd = (gbp*1.5);
cout << "Equivalent in Dollers is: " << usd << endl;
}
else if (select == 2)
{
cout <<" Enter amount in Pounds to convert to Euro: ";
cin >> gbp;
euro = (gbp*1.6);
cout << "Equivalent in euros is: " << euro << endl;
}
else
cout << "Valid options 1 or 2." << endl;
return 0;
}

I'm confused -- you said you want an interest program but you wrote a currency conversion program. which is it?

Please edit your post to use code tags as described in the link in my signature.

you might first try doing the interest part with pencil & paper. Just write down what question you want to ask and then how to calculate the interest. hint: interest = principal times interest rate. Variable can not be integers because integers to not have decimal places.

[edit](Nevermind)[/edit] Please use code tags. It makes code easier to read.

First of all, your menu looks correct, although you might want to use a switch {} statement, instead of if to make the code more readable.

Inside each menu option, use a double to keep track of the interest rate. Use an if () statement to determine the interest rate. Once you've done that, calculating the final result should not be difficult. (total = (usd or euro) + (usd or euro)*interest)

I'm confused -- you said you want an interest program but you wrote a currency conversion program. which is it?

Perhaps the "interest" is the penalty for changing currencies... banks never give you the full conversion rate when exchanging currencies.

Hope this helps

its supposed to be a currency conversion program
but once the program has converted the currency it should then work out the interest rate depending on the amount converted.
example if £100 converted to USD then interest rate will be added on of 1% to the £100 to give final amount after interest.

ok will try it
i plan to put the program, into three functions one to prompt the user for the amount and currency to be converted into
the second function to do the calculation and interest calculation
and the third to display it in a certain way.

once ive put it into functions i will see how it goes and hopefully i wont have any problems

its supposed to be a currency conversion program
but once the program has converted the currency it should then work out the interest rate depending on the amount converted.
example if £100 converted to USD then interest rate will be added on of 1% to the £100 to give final amount after interest.

OK, then do what Mr. Dragon and I suggested. Work it out with pencil and paper, and use a double to keep track of the intereset rates. Remember, if you multiply the amount of money by the interest rate, the interest rate will have to be 1/100 of the amount in the percentage. For example, 5% would be 0.05. Then you add the amount of money to that result. Or you can eliminate the need to add the amount of money to the result by adding 1 to the interest rate before multiplying. Hope this makes sense.

ive now put the program into functions ut ive got errors saying undefined symbol commission in function main? dont know how to fix it can someone help me, dont know whether the function structure might be wrong.
coding shown below

#include <iostream.h>
 
//function declarations
void inputAmount(int&);
int calCommission(int,int, int);
int main()
{//start of function main
int gbp;
int usd;
int euro;
inputAmount (gbp);
commission= calCommission(gbp,usd,euro);
}//end of function main
 
//definition of function inputAmount
void inputAmount (int&gbp)
int select= 0;
{//start of function inputAmount
cout << "Please select from the following: " << endl;
cout << "1) Pounds to US doller" << endl;
cout << "2) Pounds to Euro" << endl << endl;
cout << "Enter: ";
cin >> select;
if (select == 1)
{
cout << " Enter amount in Pounds to convert to Dollers: ";
cin >> gbp;
}
else if (select == 2)
{
cout <<" Enter amount in Pounds to convert to Euro: ";
cin >> gbp;
}
else
cout << "Valid options 1 or 2." << endl;
return 0;
}//end of function inputAmount
 
 
//definition of function calCommission
int calCommission(int usd, int euro)
{//start of function calCommission
if (select==1 and gbp <= 1000)
commission= (usd or euro)+(usd or euro)*0.01)
cout<<"Total Amount after commision:£"<<total; 
}
else if (select==2 and gbp >1000)
commission= (usd or euro)+(usd or euro)*0.03)
cout<<"Total Amount after commision:£"<<total;
}//end of function calCommission

Just to let you know, BBCode tags have a starting and ending tag. Put [code] at the beginning of your code, and [/code] at the end of your code. (At the moment, you didn't put a proper closing tag on your code, which is why they didn't display properly.)

I see you are using degraded and old coding styles. #include <iostream.h> should be #include <iostream>, and then either prefixing all Standard Template Library objects with std::, or using the statement using namespace std; after including iostream.

In your main function:

int main()
{//start of function main
    int gbp;
    int usd;
    int euro;
    inputAmount (gbp); // shouldn't it be inputAmount(&gbp) ?
    commission= calCommission(gbp,usd,euro); // why are you passing 3 parameters to a 2-parameter function?
}//end of function main

Where did commission come from? You never declared it, so of course the compiler will give errors on that.

Remember, all instructions/statements must be inside the function, unless you meant it to be global, in which case it should not be sandwiched in between inputAmount() and the starting brace. However, if you would follow my recommendation, move it inside the function so it's not global.

void inputAmount (int&gbp)
int select= 0;
{//start of function inputAmount
cout << "Please select from the following: " << endl;

Also, I'm noticing that you're trying to use select inside of calCommission(). This does not work, because it was (should have been) declared inside of inputAmount(). Your best option right now is to make inputAmount() return the selection, and use this as a parameter for calComission().

That way, you're using proper programming practices and not using globals.

In calCommission, there's this variable you're using called "commission", which you never declared. Also:

//definition of function calCommission
int calCommission(int usd, int euro)
{//start of function calCommission
if (select==1 and gbp <= 1000) // missing '{'
commission= (usd or euro)+(usd or euro)*0.01) // missing ';'
cout<<"Total Amount after commision:£"<<total;
}
else if (select==2 and gbp >1000) // missing '{'
commission= (usd or euro)+(usd or euro)*0.03) // missing ';'
cout<<"Total Amount after commision:£"<<total;
}//end of function calCommission

As you can see, there are a number of errors in the code ^_^. I've commented the errors so you can see them.

Hope this helps

thanks that helps alot
i will implement those changes and see what happens

how would i make inputAmount return the selection, and use this as a parameter for calCommision?

Create a switch case in the function inputAmount( ) , accept values from the user regarding their option, return the selected value using the return statement.

Store the returned value in a variable in main and then invoke the calculateCommission( ) function using the value returned from the inputAmount( ) function.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.