Помогите пожалуйста! Делфи. Выдаёт ошибку в конце. (else)
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
edt1: TEdit;
Edit1: TEdit;
Edit2: TEdit;
Label4: TLabel;
Edit3: TEdit;
lbl1: TLabel;
edt2: TEdit;
lbl2: TLabel;
edt3: TEdit;
btn1: TButton;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
a,b,c,d,x1,x2:Double;
implementation
{$R *.dfm}
procedure TForm1.btn1Click(Sender: TObject);
begin
a:=StrToFloat(edt1.Text);
b:=StrToFloat(Edit1.Text);
c:=StrToFloat(Edit2.Text);
d:=Sqr(b)-4*a*c;
Edit3.Text:=FloatToStr(d);
if d>=0 then
x1:=(-b-sqrt(d))/2*a;
x2:=(-b+sqrt(d))/2*a;
edt2.Text:=FloatToStr(x1);
edt3.Text:=FloatToStr(x2);
else ShowMessage('Корней нет');
end;
end.
Answers & Comments
Verified answer
Unit Unit1;interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
eA: TEdit;
eB: TEdit;
eC: TEdit;
Label4: TLabel;
eD: TEdit;
lbl1: TLabel;
eX1: TEdit;
lbl2: TLabel;
eX2: TEdit;
btn1: TButton;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.btn1Click(Sender: TObject);
var
a, b, c, d: Double;
begin
a := StrToFloat(eA.Text);
b := StrToFloat(eB.Text);
c := StrToFloat(eC.Text);
d := Sqr(b) - 4 * a * c;
eD.Text := FloatToStr(d);
if d >= 0 then begin
eX1.Text := FloatToStr((-b - sqrt(d)) / 2 * a);
eX2.Text := FloatToStr((-b + sqrt(d)) / 2 * a);
end
else ShowMessage('Корней нет');
end;
end.