Mesajlar Etiketlendi ‘kök hesaplama’

C#- Winforms- Diskriminant

Yayınlandı: 04/04/2013 Kaan tarafından C# içinde
Etiketler:, , , ,

Form Tasarımı

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
double a, b, c, d, x, x1, x2;

a = Convert.ToDouble(textBox1.Text);

b = Convert.ToDouble(textBox2.Text);

c = Convert.ToDouble(textBox3.Text);

d = b * b – 4 * a * c;
if (d < 0)
{

textBox4.Text=”Reel Kök Yok!!!”;
}
else if (d == 0)
{
x = (-b) / (2 * a);
textBox5.Text = x.ToString();
textBox6.Text = x.ToString();

}
else
{

x1 = ((-b) + Math.Sqrt(d)) / (2 * a);
x2 = ((-b) – Math.Sqrt(d)) / (2 * a);
textBox5.Text = x1.ToString();
textBox6.Text = x2.ToString();

}

}
}
}