well after several days researching I managed to get this to compile but I have a problem it doesn’t work. It is my first effort with a string so that is where to start looking but I can't find a error? Would this be a logic error? The output is not complete I know.
Thank you in advance for your help,
Randy
This program would convert units from English (US) to metric
/*
* 020947X APR 2014
* Randy Williamson
* Practical C++ Programing O'Reily book
* chapter 7-1
*/
#include <iostream>
#include <string>
// TODO (randy#1#): solve logic error
int main()
{
/* declorations of variables */
doubleconst Miles_2_Kilometers = 1.609;
doubleconst Gallon_2_Liters = 3.785;
doubleconst Feet_2_Meters = 0.3048;
doubleconst Pound_2_Kilograms = 2.2046;
double numeric_value = 0; // userinput value
double result = 0; // output value to terminal
std::string unit; // user input choice
/* Input with instructions */
std::cout << "Enter a choice: mile, gallon, feet. or pound " << '\n'; // instructions to user
std::getline(std::cin, unit); // input from user
std::cout << "Enter how many units to convert" << '\n'; // instructions to user
std::cin >> numeric_value; // input from user
/* Alternation Object Area */
if (unit.compare("mile") == 0);{
result = numeric_value / Miles_2_Kilometers;
}
if (unit.compare("gallon") == 0); {
result = numeric_value / Gallon_2_Liters;
}
if (unit.compare("feet") == 0); {
result = numeric_value * Feet_2_Meters;
}
if (unit.compare("pound") == 0 ); {
result = numeric_value * Pound_2_Kilograms;
}
/* output to user terminal*/
std::cout << "The results are " << unit << " equal " << result;
return 0;
}