C# Windows forms application hesap makinesi

Redux89

Hectopat
Katılım
3 Ekim 2020
Mesajlar
1.088
Çözümler
1
Daha fazla  
Cinsiyet
Erkek
[CODE lang="cpp" title="C# Windows Forms"]private void button1_Click(object sender, EventArgs e)
{
int sayi1, sayi2, toplam, fark, carpma, bolum;
sayi1 = Convert.ToInt32(textBox1.Text);
sayi2 = Convert.ToInt32(textBox2.Text);
toplam = sayi1 + sayi2;
fark = sayi1 - sayi2;
carpma = sayi1 * sayi2;
bolum = sayi1 / sayi2;
label4.Text = "Toplam: " + toplam + "\n" + "Fark: " + fark + "\n" + "Çarpma: " + carpma + "\n" + "Bölüm: " + bolum;
MessageBox.Show("Toplam: " + toplam + "\n" + "Fark: " + fark + "\n" + "Çarpma: " + carpma + "\n" + "Bölüm: " + bolum);
}[/CODE]

Bu kodu yazdım çalışıyor ancak çıkarma işleminin sonucunun başına "-" işareti koyuyor ve bölmedede her ne yazarsam yazayım 0 çıkıyor.
 
Böyle algoritma kötü olmuş. Kullanıcı istediğine göre yapmalı. Değerler üst üste bindiği için mesela önce topluyor sonra toplanan değeri bölüyor. Bunları ayrı ayrı fonksiyonlar ile yapmanız lazım. Sorun bu.

Zaten öyle bir şey yaptım ama böyle bir şey de yapmak istedim.

[CODE lang="csharp" title="C# Windows Forms"]private void button1_Click(object sender, EventArgs e)
{
int sayi1, sayi2, sonuc;
sayi1 = Convert.ToInt32(textBox1.Text);
sayi2 = Convert.ToInt32(textBox2.Text);
sonuc = sayi1 + sayi2;
label4.Text = sonuc.ToString();
}

private void button2_Click(object sender, EventArgs e)
{
int sayi1, sayi2, sonuc;
sayi1 = Convert.ToInt32(textBox1.Text);
sayi2 = Convert.ToInt32(textBox2.Text);
sonuc = sayi1 * sayi2;
label4.Text = sonuc.ToString();
}

private void button3_Click(object sender, EventArgs e)
{
int sayi1, sayi2, sonuc;
sayi1 = Convert.ToInt32(textBox1.Text);
sayi2 = Convert.ToInt32(textBox2.Text);
sonuc = sayi1 / sayi2;
label4.Text = sonuc.ToString();
}

private void button4_Click(object sender, EventArgs e)
{
int sayi1, sayi2, sonuc;
sayi1 = Convert.ToInt32(textBox1.Text);
sayi2 = Convert.ToInt32(textBox2.Text);
sonuc = sayi1 - sayi2;
label4.Text = sonuc.ToString();
}[/CODE]

Onun kodu da burada. Bunda bir hata yok değil mi?
 
Son düzenleyen: Moderatör:
Zaten öyle bir şey yaptım ama böyle bir şey de yapmak istedim.

[CODE lang="csharp" title="C# Windows Forms"]private void button1_Click(object sender, EventArgs e)
{
int sayi1, sayi2, sonuc;
sayi1 = Convert.ToInt32(textBox1.Text);
sayi2 = Convert.ToInt32(textBox2.Text);
sonuc = sayi1 + sayi2;
label4.Text = sonuc.ToString();
}

private void button2_Click(object sender, EventArgs e)
{
int sayi1, sayi2, sonuc;
sayi1 = Convert.ToInt32(textBox1.Text);
sayi2 = Convert.ToInt32(textBox2.Text);
sonuc = sayi1 * sayi2;
label4.Text = sonuc.ToString();
}

private void button3_Click(object sender, EventArgs e)
{
int sayi1, sayi2, sonuc;
sayi1 = Convert.ToInt32(textBox1.Text);
sayi2 = Convert.ToInt32(textBox2.Text);
sonuc = sayi1 / sayi2;
label4.Text = sonuc.ToString();
}

private void button4_Click(object sender, EventArgs e)
{
int sayi1, sayi2, sonuc;
sayi1 = Convert.ToInt32(textBox1.Text);
sayi2 = Convert.ToInt32(textBox2.Text);
sonuc = sayi1 - sayi2;
label4.Text = sonuc.ToString();
}[/CODE]

Onun kodu da burada. Bunda bir hata yok değil mi?

Hata göremedim.
 

Yeni konular

Geri
Yukarı