private void button2_Click(object sender, EventArgs e) { double sayi1, sayi2; if (textBox1.Text == "") { MessageBox.Show("Bir sayı giriniz"); return; } else { textBox1.Text = OrtakSinif.NoktayiVirgule(textBox1.Text); sayi1 = Convert.ToDouble(textBox1.Text); } if (textBox2.Text == "") { MessageBox.Show("Bir sayı giriniz"); return; } else { textBox2.Text = OrtakSinif.NoktayiVirgule(textBox2.Text); //sonuc.Replace(".", ","); //çalışıyor sayi2 = Convert.ToDouble(textBox2.Text); } //float bolme = 0.15F; double cikarma = (sayi1 - sayi2); double sonuc = Math.Round((double)cikarma, 4); //çalışıyor //string sonuc = String.Format("{0:f}", cikarma); //çalışıyor virgülden sonra 2 hane gösteriyor // MessageBox.Show(sonuc.ToString()); textBox3.Text = sonuc.ToString(); }
private void button3_Click(object sender, EventArgs e) { double sayi1, sayi2; if (textBox1.Text == "") { MessageBox.Show("Bir sayı giriniz"); return; } else { textBox1.Text = OrtakSinif.NoktayiVirgule(textBox1.Text); sayi1 = Convert.ToDouble(textBox1.Text); } if (textBox2.Text == "") { MessageBox.Show("Bir sayı giriniz"); return; } else { textBox2.Text = OrtakSinif.NoktayiVirgule(textBox2.Text);//sonuc.Replace(".", ","); //çalışıyor /* Eğer Sinif ve Fonksiyon oluşturma derslerine yetişebilirsem, sizinle "OrtakSinif.NoktayiVirgule" * sınıf ve metodunu nasıl oluşturduğumu paylaşacağım */ sayi2 = Convert.ToDouble(textBox2.Text); } if (sayi2 == 0) { MessageBox.Show("bölen 0 olamaz!"); return; } //float bolme = 0.15F; double bolme = (sayi1 / sayi2); double sonuc = Math.Round((double)bolme, 4); //çalışıyor //string sonuc = String.Format("{0:f}", bolme); //çalışıyor virgülden sonra 2 hane gösteriyor //MessageBox.Show(sonuc.ToString()); textBox3.Text = sonuc.ToString(); }