radioButton kullanarak prosedür ile hesap makinası

public static int tgelen1, tgelen2,sonuc;

private void cagir()
{

if (textBox1.Text == “” && textBox2.Text == “”)
{
MessageBox.Show(“Birinci sayı ve ikinci sayı kısmını doldurunuz”);
}
else
{

tgelen1 = int.Parse(textBox1.Text);
tgelen2 = int.Parse(textBox2.Text);
}
}

void topla()
{
sonuc = tgelen1 + tgelen2;
listBox1.Items.Add(tgelen1.ToString() + ” ” + “+” + tgelen2.ToString() + ” ” + “=” + sonuc.ToString());
}

void cikar()
{
sonuc = tgelen1 – tgelen2;
listBox1.Items.Add(tgelen1.ToString() + ” ” + “-” + tgelen2.ToString() + ” ” + “=” + sonuc.ToString());
}

void carp()
{
sonuc = tgelen1 * tgelen2;
listBox1.Items.Add(tgelen1.ToString() + ” ” + “*” + tgelen2.ToString() + ” ” + “=” + sonuc.ToString());
}

void bol()
{
sonuc = tgelen1 * tgelen2;
listBox1.Items.Add(tgelen1.ToString() + ” ” + “/” + tgelen2.ToString() + ” ” + “=” + sonuc.ToString());
}

private void hesapla_Click(object sender, EventArgs e)
{

cagir();

if (radioButton1.Checked == true) topla();
else if (radioButton2.Checked == true) cikar();
else if (radioButton3.Checked == true) carp();
else if (radioButton4.Checked == true) bol();

}

tuna

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir