Q:

using radio buttons to do some basic maths

i am making a program that will calculate  how much someone needs to pay if they have had there vehicle parked. I am trying to use radio buttons to select the type of vehicle. when cars(radiobutton1) is selected the algorithm works but when  trucks (radiobutton2)is selected it will not work. here is my code 
 // cars 
        if (radioButton1.Checked == true)
        {

            int hac = Convert.ToInt16(txthrs.Text);
            int h1c = 5;
            int h2c = 3;

            if (txthrs.Text == "1") ;
            money.Text = h1c.ToString();

            if (hac < 1) ;
            money.Text = (h1c + (hac - 1) * h2c).ToString();
            // end of cars 
            // trucks 
            if (radioButton2.Checked == true)
            {

                int hat = Convert.ToInt16(txthrs.Text);
                int h1t = 6;
                decimal h2t = 3.5m;

                if (txthrs.Text == "1") ;
                money.Text = h1t.ToString();

                if (hat < 1) ;
                money.Text = (h1t + (hat - 1) * h2t).ToString();
            }
        }
    }
}

}

A:

You have nested your if statements, the second if statement will only execute if radio button one is checked. Move the second if block out of the first.

