-
Notifications
You must be signed in to change notification settings - Fork 0
/
unit4.pas
83 lines (68 loc) · 1.8 KB
/
unit4.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
unit Unit4;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
ExtCtrls;
const
filename='density_table_en.csv';
type
{ TFCube }
TFCube = class(TForm)
CBCompute: TButton;
EditA: TEdit;
EditM: TEdit;
Image1: TImage;
Label1: TLabel;
Label2: TLabel;
Lbl_found: TLabel;
Lbl_eps: TLabel;
Lbl_dRho: TLabel;
LblDensity: TLabel;
procedure CBComputeClick(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
FCube: TFCube;
a,V,m,Rho,rmin:Real;
s:String;
imin,i,valcode:Longint;
implementation
uses Unit1;
{$R *.lfm}
{ TFSphere }
procedure TFCube.CBComputeClick(Sender: TObject);
begin
Val(EditA.Text,a,valcode);
if a=0 then a:=0.0000001;
a:=a/1000;
Val(EditM.Text,m,valcode);
m:=m/1000;
V:=a*a*a;
Rho:=m/V;
Str(Rho:0:3,s);
LblDensity.Caption:='Получена плотность ' + s + ' кг/м3';
rmin:=30000;
imin:=1;
for i:=1 to n do
begin
if Abs(rho-dt[i].d)<rmin then
begin
rmin:=Abs(rho-dt[i].d);
imin:=i;
end;
end;
if dt[0].d=-1 then Lbl_found.caption:=('База плотностей не считана с диска.')
else begin
Str(dt[imin].d:0:3,s);
Lbl_found.Caption:='Материал детали - ' + dt[imin].name + ' (' + s + ')';
Str(Rho - dt[imin].d :0:3,s);
Lbl_dRho.Caption:='Абсолютная погрешность Δρ=' + s;
Str((Rho - dt[imin].d)/dt[imin].d *100 :0:2,s);
Lbl_eps.Caption:='Относительная погрешность ε=' + s + ' %';
end;
end;
end.