#include <iostream>
int main()
{
double converter;
char cf;
while(true)
{
while (std::cin)
{
std::cout << "Enter the value you want to convert." << std::endl;
std::cin >> converter >> cf;
if (cf == 'F' || cf == 'f')
{
std::cout << "New value: " << ((cf-32)*5)/9 << std::endl << std::endl;
}
elseif (cf == 'C' || cf == 'c')
{
std::cout << "New value: " << ((cf*9)/5)+32 << std::endl << std::endl;
}
else
{
std::cout << "Error." << std::endl << std::endl;
}
}
std::cin.clear();
}
}
Entering 0 C should get it to convert to Fahrenheit (and everything should evaluate to double, not int,) so I'm obviously doing something wrong. But what?
This is a minor error, heh. You formula's are using "cf", the character, instead of "converter", the value of the temperature. Try adjusting that and see if it works.