Information Technology Articles :: SEO Tips :: WAP Articles :: Search Engine Marketing :: Internet Tips

Goedangilmu

Source Code Metode Simpson

Posted on May 9th, 2007 in Programming, 272 views

Berikut ini merupakan source code Metode Simpson yang saya buat menggunakan Delphi.

var
i,n:integer;
a,b,h,x,fx,hasil,jumlah:real;
nilai:array [0..10] of real;
y:array [0..10] of real;
begin
a:=strtofloat(edit2.text);
b:=strtofloat(edit1.text);
n:=strtoint(edit3.text);

h:=(b-a)/n;
jumlah:=0;

for i:=0 to n do
begin
x:=a+(i*h);
fx:=(2*(x*x))+5;
nilai[i]:=fx;
end;

for i:=0 to n do
begin
if (i=0) or (i=n) then
begin
y[i]:=nilai[i];
end
else
begin
if (i mod 2)=0 then
begin
y[i]:=2*nilai[i];
end
else
begin
y[i]:=4*nilai[i];
end;
end;

jumlah:=jumlah+y[i];
end;

hasil:=(h/3)*jumlah;

edit4.Text:=floattostr(hasil);
end;

Related Posts :

Published by Adith

No Comments

Leave a comment