I can't seem to figure out why this isn't returning the quotient of inches*2.54, even though I think to convert from inches to centimeters it should be inches/2.54. Anyways I can't get that value, I either get a warning saying "the address of 'float inches_to_centimeters(float)', will always be 'true' " or else I get an error saying something about the stuff under the { after if. I only get the error when I change the return in the function to "return (inches*2.54);
Here's the code, if anyone can help...
Code:
/*
* Name : xxxxxx xxxxxxx
* Course : cps
* Assignment : Homework03
* Description : Convert from english units to metric and vice versa.
*/
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
float inches_to_centimeters(float inches);
int main()
{
string conversion;
cout << "Please enter the name of the units you would like to convert to" << endl;
cout << " -Ex. to convert from inches to centimeters, enter \"inches\"" << endl;
cout << "The following are the available conversions: " << endl;
cout << " inches, centimeters, feet, meters, miles, kilometers" << endl;
cin >> conversion;
if (conversion == "inches")
{
float inches_to_centimeters(float inches);
cout << inches_to_centimeters << endl;
}
else
{
cout << "no" << endl;
}
}
/*
* Name: inches_to_centimeters
* Purpose: Convert inches to centimeters
* Receive: A number in inches
* Return: Equivalent number in centimeters
*/
float inches_to_centimeters(float inches)
{
cout << "The number of inches is: ";
cin >> inches;
(inches*2.54);
return 0;
}