I have been working on this problem all weekend, and just cant see what I am doing wrong. I am very new to programming, so that is my excuse.
I am using VC++ and here is the code I have put together. It compiles fine but the calculation is all messed up. I have know idea what I am doing wrong???? I sure hope this pastes right???
Code:
/*************header files**************/
#include <iostream>
using namespace std;
//constants defined
const float GBP = float (0.6997); //Great Britain Pound per US Dollar on 3/21/02
const float CAD = float (1.5808); //Canadian Dollar per US Dollar on 3/21/02
const float INR = float (48.78); //Indian Rupee per US Dollar on 3/21/02
const float JPY = float (131.86); //Japanese Yen per US Dollar on 3/21/02
const float MXN = float (9.063); //Mexican Peso per US Dollar on 3/21/02
/***********Function Prototypes**********/
void title();
void getInput(float &);
float calcGBP(const float, float, float&);
float calcCAD(const float, float, float&);
float calcINR(const float, float, float&);
float calcJPY(const float, float, float&);
float calcMXN(const float, float, float&);
/***********Main Program****************/
int main()
{
//variables
float USD = 0.0;
//input
cout << " ";
title();
cout << endl << endl;
getInput(USD);
//output
system ("cls");
cout << " ";
title();
cout << endl << endl;
cout << fixed;
cout.precision(2);
cout << USD << " US Dollars" << " equates to " << calcGBP << " Great British Pounds" << endl << endl;
cout << USD << " US Dollars" << " equates to " << calcCAD << " Canadian Dollars" << endl << endl;
cout << USD << " US Dollars" << " equates to " << calcINR << " Indian Rupees" << endl << endl;
cout << USD << " US Dollars" << " equates to " << calcJPY << " Japanese Yen" << endl << endl;
cout << USD << " US Dollars" << " equates to " << calcMXN << " Mexican Pesos" << endl << endl;
return 0;
}
/***********Function Definitions*************/
//title function
void title()
{
cout << "Currency Conversion";
}//end title function
//getInput function
void getInput(float &USD)
{
cout << "Enter Amt of US Dollars to Convert: ";
cin >> USD;
}//end getInput function
//calcGBP function
float calcGBP(const float GBP, float USD, float&britain)
{
//input items
getInput(USD);
//calculations
britain = USD * GBP;
return britain;
}//end calcGBP function
//calcCAD function
float calcCAD(const float CAD, float USD, float&canada)
{
//input items
getInput(USD);
//calculations
canada = CAD * USD;
return canada;
}//end calcCAD function
//calcINR function
float calcINR(const float INR, float USD, float&india)
{
//input items
getInput(USD);
//calculations
india = INR * USD;
return india;
}//end calcINR function
//calcJPY function
float calcJPY(const float JPY, float USD, float&japan)
{
//input items
getInput(USD);
//calculations
japan = JPY * USD;
return japan;
}//end calcJPY function
//calcMXN function
float calcMXN(const float MXN, float USD, float&mexico)
{
//input items
getInput(USD);
//calculations
mexico = MXN * USD;
return mexico;
}//end calcMXN function