Hello I have created a simple program that converts celsius to farenheit but, for some reason the math operation i used is not giving me the correct result. celsius to farenheit is
F = 9/5 * C + 32. I broke down the problem and the error lies with the fraction (9/5). For some reason this calculation gives me a result of 1. Obviously im missing something here. Any help would be appreciated and thank you. here is my code...
private void btnF_Click(object sender, EventArgs e)
{
double cel, total;
cel = Double.Parse(txtC.Text);
total = 9/5 * cel + 32;
lblResult.Text = total.ToString();
}
would i have to cast the variable to float? and if i do cant that cause loss of data?
do I have to use a Math method? what am i doing wrong?