I'm a student just starting my first C# class in school, our first assignment was to make a simple console app to convert temperatures from Fahrenheit to Celsius. Being the over-achiever that I am, I decided to make a second project and create a form app. It's a very simple project that I have almost complete and I have one problem with it that is driving me nuts. I used 2 radio buttons for the user to determine whether to convert to Fahrenheit or to Celsius, they select a button, enter a temperature into a text box and click the convert button(button1) here is the code for button1:
public void button1_Click(object sender, EventArgs e)
{
bool radioButton1_CheckedChanged = true;
bool convertToCelsius_CheckChanged = true;
if (radioButton1_CheckedChanged == true)
{
convToF(double.Parse(Current.Text));
}
else if (convertToCelsius_CheckedChanged ==true)
{
convToC(double.Parse(Current.Text));
}
}
void convToF(double tempC)
{
double convertToFahr1 = tempC * 9 / 5;
double convertToFahr2 = convertToFahr1 + 32;
MessageBox.Show("F=(C*9/5)+32= " + convertToFahr2);
}
void convToC(double tempF)
{
double convertToCels1 = tempF - 32;
double convertToCels2 = convertToCels1 * 5 / 9;
MessageBox.Show("C=(f-32)*5/9= " + convertToCels2);
}
The problem is, whenever the form is run, and the convert button is pressed, it only displays the Fahrenheit conversion no matter what radio button is selected. I've searched numerous tutorials and my text book, I've tried every possible combination of true and false bool statements, ifs, elses, else ifs...and still will only display the fahrenheit value...can anyone point me in the right direction?