123
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Math;
type
TTfrmMain = class(TForm)
edta1: TEdit;
edta2: TEdit;
edtv1: TEdit;
edtv2: TEdit;
edtS: TEdit;
Button1: TButton;
pnlResult: TPanel;
lblResult: TLabel;
Tpnl: TPanel;
LblInfo: TLabel;
lblResult1: TLabel;
lblResult2: TLabel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
TfrmMain: TTfrmMain;
implementation
{$R *.dfm}
procedure TTfrmMain.Button1Click(Sender: TObject);
var
x1,x2,x3,x4,x5,x6,x7:Extended;
begin
if
(trystrtofloat(edta1.text,x1)) and
(trystrtofloat(edta2.text,x2)) and
(trystrtofloat(edtv1.text,x3)) and
(trystrtofloat(edtv2.text,x4)) and
(trystrtofloat(edtS.text,x5)) and
(x1>0) and (x2>0) and (x3>0) and (x4>0) and (x5>0)
then
begin
x6:=(-(x3+x4)+Sqrt(Sqr(x3+x4)+2*(x1+x2)*x5))/(x1+x2);
x7:=(-(x3+x4)-Sqrt(Sqr(x3+x4)+2*(x1+x2)*x5))/(x1+x2);
if x6>0
then
x6:=x6
else
x6:=x7;
lblResult.Caption:='время= '+FloatToStrF(x6,ffGeneral,6,3)+' сеукнд';
x6:=x6/60;
lblResult1.Caption:='время= '+FloatToStrF(x6,ffGeneral,6,3)+' минут';
x6:=x6/60;
lblResult2.Caption:='время= '+FloatToStrF(x6,ffGeneral,6,3)+' часов';
end
else
begin
lblResult.Caption:='Введены неверные данные';
lblResult1.Caption:='Введены неверные данные';
lblResult2.Caption:='Введены неверные данные';
end;
end;
end.
вот чтобы x6 выводилась так..
|