using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
if (Checker(textBox1) && Checker(textBox2) && Checker(textBox1))
{
Calculate();
}
}
public void Calculate()
{
int count = int.Parse(textBox1.Text);
int a = int.Parse(textBox1.Text);
int b = int.Parse(textBox2.Text);
int c = int.Parse(textBox3.Text);
double d = Math.Pow(b, 2) - (4 * a * c);
double x1;
double x2;
if (d > 0)
{
x1 = (-b - Math.Sqrt(d) / (2 * a));
x2 = (-b + Math.Sqrt(d) / (2 * a));
}
if (d == 0)
{
x1 = (-b) / (2 * a);
label2.Text = "x1 = " + x1.ToString();
}
if (d<0)
{
label2.Text = "нет корней";
label3.Text = "нет корней";
}
label1.Text = "D = " + d.ToString();
}
public bool Checker(TextBox textBox)
{
if (int.TryParse(textBox.Text, out int result))
{
return true;
}
else
{
label2.Text = " НЕ ЗАПОЛНЕНО";
return false;
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void label3_Click(object sender, EventArgs e)
{
}
}
}