SORU:İkinci derece bir denklemin a,b,c katsayıları textBox kontrollerine giriliyor. Hesapla düğmesine tıklandığında denklemin köklerini hesaplayan C# programı?


gg

privatevoid button1_Click(object sender, EventArgs e)

{

int a, b, c;
double d,x2,x1,i;
a =int.Parse(textBox1.Text);
b =int.Parse(textBox2.Text);
c =int.Parse(textBox3.Text);
d = b * b – 4 * a * c;

if (d < 0)
MessageBox.Show(“Reel kök yoktur”);

if (d == 0)
 {
i = (-b / 2 * a);
MessageBox.Show(“çift katlı tek kök var” + i.Tostring());
 }

if (d > 0)
{
x1 = (-b +Math.Sqrt(d) / 2 * a);
x2 = (-b –Math.Sqrt(d) / 2 * a);
MessageBox.Show(“Reel kök var “ + x1.ToString() + x2.ToString());
 }
}

SORU: textboxa girilen değere göre hangi gün olduğunu messagebox ile bildiren C# program.


DD

privatevoid button1_Click(object sender, EventArgs e)

{
int a;
a =int.Parse(textBox1.Text);

         switch(a)
 {

case 1: MessageBox.Show(“Pazartesi”);break;

case 2: MessageBox.Show(“Salı”);break;

case 3: MessageBox.Show(“Çarşamba”);break;

case 4: MessageBox.Show(“Perşembe”);break;

case 5: MessageBox.Show(“Cuma”);break;

case 6: MessageBox.Show(“cumartesi”);break;

case 7: MessageBox.Show(“Pazar”);break;

defaultMessageBox.Show(“1 ile 7 arasında bir değer giriniz”);break;

}

}

SORU: textboxların içindeki sayılara butonlardaki işlemleri yaptırıp sonuc olarak labele yazdırmak


aa

privatevoid button1_Click(object sender, EventArgs e)

{

int sayi,sayi2, sonuc;

sayi =int.Parse(textBox1.Text);

sayi2 =int.Parse(textBox2.Text);

sonuc = sayi + sayi2;

label2.Text = sonuc.ToString();

label1.Text =“+”;

}

privatevoid button2_Click(object sender, EventArgs e)

{

int sayi, sayi2, sonuc;

sayi =int.Parse(textBox1.Text);

sayi2 =int.Parse(textBox2.Text);

sonuc = sayi – sayi2;

label2.Text = sonuc.ToString();

label1.Text =“-“;

}

privatevoid button3_Click(object sender, EventArgs e)

{

int sayi, sayi2, sonuc;

sayi =int.Parse(textBox1.Text);

sayi2 =int.Parse(textBox2.Text);

sonuc = sayi * sayi2;

label2.Text = sonuc.ToString();

label1.Text =“*”;

}
privatevoid button4_Click(object sender, EventArgs e)

{

int sayi, sayi2, sonuc;

sayi =int.Parse(textBox1.Text);

sayi2 =int.Parse(textBox2.Text);

sonuc = sayi / sayi2;

label2.Text = sonuc.ToString();

label1.Text =“/”;
        }

SORU: textboxların içindeki değerler ekle butonuna tıklandığında listboxın içine eklenecek. sil dediğimizde textboxlardaki değerler silinecek. çık butonuna tıklandığında ise program tamamen kapanacak.


Adsız

Bu ekranda gördüğümüz örneğin kodlarını c# da yazalım şimdi:

Aşağıda gördüğünüz gibi hangi işlemi yapmak istiyorsak o butonun click olayına kodlarını yazıyoruz.

privatevoid button1_Click(object sender, EventArgs e)

{

listBox1.Items.Add(textBox1.Text);

listBox1.Items.Add(textBox2.Text);

listBox1.Items.Add(textBox3.Text);

}

privatevoid button2_Click(object sender, EventArgs e)

{

textBox1.Clear();

textBox2.Clear();

textBox3.Clear();

}

privatevoid button3_Click(object sender, EventArgs e)

{

Close();

}