I wrote this utility in C++:
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
float f = 0.0;
float c = 0.0;
float frac = 0.0;
const float adj = 32.0;
int uChoice = 0;
bool lFlag = false;
do
{
system("CLS");
cout << "Temperature conversion utility, F to C and C to F.\n\n";
cout << "Please choose:\n";
cout << " 1. degrees F to degrees C\n";
cout << " 2. degrees C to degrees F\n\n";
cout << "Your choice --> ";
cin >> uChoice;
switch(uChoice)
{
case 1: frac = 5.0/9.0;
cout << "Please enter the temp in degrees F --> ";
cin >> f;
c = frac * (f - adj);
cout << "\nTemp in degrees C = " << c << "\n";
lFlag = true;
break;
case 2: frac = 9.0/5.0;
cout << "Please enter the temp in degrees C --> ";
cin >> c;
f = (frac * c) + adj;
cout << "\nTemp in degrees F = " << f << "\n";
lFlag = true;
break;
default: cout << "\nExiting...\n\n";
lFlag = false;
};
system("PAUSE");
}while(lFlag != false);
return EXIT_SUCCESS;
}
Notice where the parentheses are within the formulas -- they're important.
Hope this helps.
Cheers.