unit U_calculadora;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Buttons, math;

type
  Tbaskra = class(TForm)
    lb_1: TLabel;
    lb_2: TLabel;
    txt_b: TEdit;
    txt_c: TEdit;
    lb_3: TLabel;
    txt_a: TEdit;
    Label1: TLabel;
    btn_resolver: TSpeedButton;
    txt_resultado1: TEdit;
    Label2: TLabel;
    txt_resultado2: TEdit;
    Label3: TLabel;
    procedure btn_resolverClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  baskra: Tbaskra;

implementation


{$R *.dfm}

procedure Tbaskra.btn_resolverClick(Sender: TObject);
   var
   a, b, c, resultado1, resultado2, resultado3, resultado4, delta : double;
begin
  a := strtofloat(txt_a.Text);
  b := strtofloat(txt_b.Text);
  c := strtofloat(txt_c.Text);
  delta := b*b-(4*a*c);
  if delta < 0 then
  showmessage('Não existe raiz para o resultado obtido pela equação do delta com os números apresentados. ')
  else
  resultado1 := (-b+power(delta,1/2));
  resultado2 := (-b-power(delta,1/2));
  resultado3 := resultado1/2*a ;
  resultado4 := resultado2/2*a ;
  txt_resultado1.Text := floattostr(resultado3);
  txt_resultado2.Text := floattostr(resultado4);


end;

end.
