I wrote a program that converts Celsius to Fahrenheit and vice versa. when converting Celsius to Fahrenheit I used the formula (9/5) * Celsius + 32. but that didn't work, I discovered that 9/5 was returning 1 rather than 1.8 and I'm not sure why that is. I fixed the problem by just using the formula: 1.8 * Celsius + 32, but I don't understand why I had to. The Fahrenheit to Celsius bit works fine.
My code :
double dubCelsius;
double dubFarenheit;
if (rbtnFar.Checked)
{
double.TryParse(txtInput.Text, out dubFarenheit);
dubCelsius = (dubFarenheit - 32) * 5 / 9;
txtResult.Text = dubCelsius.ToString();
}
if (rbtnCel.Checked)
{
double.TryParse(txtInput.Text, out dubCelsius);
dubFarenheit = 1.8 * dubCelsius + 32;
txtResult.Text = dubFarenheit.ToString();
}
I have a feeling the answer to this is going to be very obvious but I just cant figure it out.