i have this problem from a beginning c sharp book this for conversion between Fahrenheit and Celsius.
private void button1_Click(object sender, EventArgs e)
{
float fahr, cel;
if (Celsius.Checked == true)
{
fahr = float.Parse(textBox1.Text);
cel = (5/9)*(fahr-32);
richTextBox1.Text = "The Degree in Celsius is:" + cel.ToString() + Environment.NewLine + "cool isn't it!?";
}
else if (Fahrenheit.Checked == true )
{
cel = float.Parse(textBox1.Text);
fahr = ((9 * cel)/5)+ 32;
richTextBox1.Text = "The degree in Fahrenheit is:" + fahr.ToString() + Environment.NewLine + "cool is it!?";
}
when i want to get Celsius from a Fahrenheit it keeps giving me 0 even though the formula appears to be true to me.
what's wrong here?
because i think the problem lies here:
if (Celsius.Checked == true)
{
fahr = float.Parse(textBox1.Text);
cel = (5/9)*(fahr-32);
richTextBox1.Text = "The Degree in Celsius is:" + cel.ToString() + Environment.NewLine + "cool isn't it!?";
maybe i have something wrong with Order of Ops but i think it's True? thanks for help.