var
a,b,h,k,luas:real;
n,i,j:integer;
x,fx,l:array[0..100]of real;
begin
a:=StrToFloat(Edit1.Text);
b:=StrToFloat(Edit2.Text);
n:=StrToInt(Edit3.Text);
if a>b then showmessage ('ulangi input selang, asumsikan a<b');
if a=b then Edit4.Text:='0';
j:=-1;
for i:=1 to n+1 do
begin
j:=j+1;
ListBox1.Items.Add(IntToStr(j));
end;
h:=(b-a)/n;
k:=a;
ListBox2.Items.Add(FloatToStr(k));
for i:=1 to ListBox1.Count-1 do
begin
k:=k+h;
ListBox2.Items.Add(FloatToStr(k));
end;
for i:=0 to ListBox2.Count-1 do
begin
x[i]:=StrToFloat(ListBox2.Items[i]);
fx[i]:=x[i]/(1+sqr(x[i]));
ListBox3.Items.Add(FloatToStr(fx[i]));
end;
for i:=1 to ListBox3.Count-1 do
begin
fx[i]:=StrToFloat(ListBox3.Items[i]);
l[i]:=(h*(fx[i-1]+fx[i]))/2;
ListBox4.Items.Add(FloatToStr(l[i]));
end;
luas:=0;
for i:=0 to ListBox4.Count-1 do
begin
l[i]:=StrToFloat(ListBox4.Items[i]);
luas:=luas+l[i];
end;
Edit4.Text:=FloatToStr(luas);
end;
»» READMORE...
a,b,h,k,luas:real;
n,i,j:integer;
x,fx,l:array[0..100]of real;
begin
a:=StrToFloat(Edit1.Text);
b:=StrToFloat(Edit2.Text);
n:=StrToInt(Edit3.Text);
if a>b then showmessage ('ulangi input selang, asumsikan a<b');
if a=b then Edit4.Text:='0';
j:=-1;
for i:=1 to n+1 do
begin
j:=j+1;
ListBox1.Items.Add(IntToStr(j));
end;
h:=(b-a)/n;
k:=a;
ListBox2.Items.Add(FloatToStr(k));
for i:=1 to ListBox1.Count-1 do
begin
k:=k+h;
ListBox2.Items.Add(FloatToStr(k));
end;
for i:=0 to ListBox2.Count-1 do
begin
x[i]:=StrToFloat(ListBox2.Items[i]);
fx[i]:=x[i]/(1+sqr(x[i]));
ListBox3.Items.Add(FloatToStr(fx[i]));
end;
for i:=1 to ListBox3.Count-1 do
begin
fx[i]:=StrToFloat(ListBox3.Items[i]);
l[i]:=(h*(fx[i-1]+fx[i]))/2;
ListBox4.Items.Add(FloatToStr(l[i]));
end;
luas:=0;
for i:=0 to ListBox4.Count-1 do
begin
l[i]:=StrToFloat(ListBox4.Items[i]);
luas:=luas+l[i];
end;
Edit4.Text:=FloatToStr(luas);
end;