I got all the rest of the code working but I just can't figure out how to convert the input into meters and centimeters. For example I know that 1 foot is 0.3048 meters, so I need to multiply the feet by 0.3048.
But every time I run it, it never converts it, it just says 6.78222e-308 meters.
Here's the code:
Code:
#include <iostream>
using namespace std;
void userInput(double& feet, double& inches);
void convertUStoMetric(double& meters, double& centimeters);
void output(double meters, double centimeters);
int main()
{
double unit, subunit;
char redo = 'y';
while (redo == 'y' || redo == 'Y')
{
userInput(unit, subunit);
convertUStoMetric(unit, subunit);
output(unit, subunit);
cout << "Would you like to run it again? Y/N: ";
cin >> redo;
cout << "\n";
}
system("pause");
return 0;
}
void userInput(double& feet, double& inches)
{
cout << "Enter the feet and inches with a space in between each: ";
cin >> feet;
cin >> inches;
cout << "\n";
}
void convertUStoMetric(double& meters, double& centimeters)
{
double total;
total = total * 0.3048;
meters = total;
}
void output(double meters, double centimeters)
{
cout << "The converted measurements are " << meters << " meters and " << centimeters << " centimeters.";
cout << "\n\n";
}
I don't understand how I'm supposed to do the convertUStoMetric conversion function.
Am I supposed to create a new variable?