uses crt, graph;
var
gd,gm,vo,x,xo,xs,c: integer;
uk,a,t:real;
k,l,m,n,o,p,q,r,s:string;
lagi:char;
const
g= 10;
procedure animasi;
begin
gd:= detect;
gm:= detect;
initgraph(gd,gm,'');
x := 0;
settextstyle(smallfont,horizdir,4);
rectangle(300,50,580,200);
str(vo:2,l);
settextstyle(smallfont,horizdir,4);
outtextxy(450,80,l) ;
outtextxy(310,80,'Kecepatan Awal       =  ');
outtextxy(480,80,'(m/s)');
str(uk:0:2,m);
settextstyle(smallfont,horizdir,4);
outtextxy(450,100,m) ;
outtextxy(310,100,'Koefisien Gesekan    = ');
outtextxy(120,305,'0');
outtextxy(170,305,'50');
outtextxy(220,305,'100');
outtextxy(270,305,'150');
outtextxy(320,305,'200');
outtextxy(370,305,'250');
outtextxy(420,305,'300');
outtextxy(470,305,'350');
outtextxy(520,305,'400');
outtextxy(570,305,'450');
outtextxy(620,305,'500');
line(0,300,120,300);
setcolor(blue);
line(120,300,640,300);
setcolor(red);
settextstyle(smallfont,horizdir,4);
setcolor(white);
outtextxy(10,320,'Permukaan Licin');
setcolor(red);
settextstyle(smallfont,horizdir,4);
outtextxy(300,320,'Permukaan Kasar');
{keterangan kecepatan awal}
str(vo:2,n);
settextstyle(smallfont,horizdir,4);
setcolor(yellow);
outtextxy(80,260,n) ;
outtextxy(10,260,'V Konstan = ');
outtextxy(100,260,'(m/s kuadrat)');
a:= (-uk*(g));
xo:=100;
if uk>=1 then halt;
repeat
x := Round(vo*t);
setcolor(8);
rectangle(x+0,286,20+x,296) ;
line(20+x,290,28+x,294);
line(28+x,294,28+x,298);
line(20+x,298,28+x,298);
circle(4+x,296,2);
circle(17+x,296,2);
delay(100);
cleardevice;
setcolor(white);
settextstyle(smallfont,horizdir,4);
rectangle(300,50,580,200);
str(vo:2,l);
settextstyle(smallfont,horizdir,4);
outtextxy(450,80,l) ;
outtextxy(310,80,'Kecepatan Awal       =  ');
outtextxy(480,80,'(m/s kuadrat)');
str(uk:0:2,m);
settextstyle(smallfont,horizdir,4);
outtextxy(450,100,m) ;
outtextxy(310,100,'Koefisien Gesekan    = ');
outtextxy(120,305,'0');
outtextxy(170,305,'50');
outtextxy(220,305,'100');
outtextxy(270,305,'150');
outtextxy(320,305,'200');
outtextxy(370,305,'250');
outtextxy(420,305,'300');
outtextxy(470,305,'350');
outtextxy(520,305,'400');
outtextxy(570,305,'450');
outtextxy(620,305,'500');
line(0,300,120,300);
setcolor(blue);
line(120,300,640,300);
setcolor(red);
settextstyle(smallfont,horizdir,4);
setcolor(white);
outtextxy(10,320,'Permukaan Licin');
setcolor(red);
settextstyle(smallfont,horizdir,4);
outtextxy(300,320,'Permukaan Kasar');
{keterangan kecepatan awal}
str(vo:2,n);
settextstyle(smallfont,horizdir,4);
setcolor(yellow);
outtextxy(80,260,n) ;
outtextxy(10,260,'V Konstan = ');
outtextxy(100,260,'(m/s kuadrat)');
a:= (-uk*(g));
xo:=100;
t:=t+0.05;
until x>=100;

if (uk=0)and(x>80) then
begin
t:=0;   xo:=100;
repeat
x := xo+round(vo*t);
setcolor(8);
rectangle(x+0,286,20+x,296) ;
line(20+x,290,28+x,294);
line(28+x,294,28+x,298);
line(20+x,298,28+x,298);
circle(4+x,296,2);
circle(17+x,296,2);
delay(100);
cleardevice;
setcolor(white);
settextstyle(smallfont,horizdir,4);
rectangle(300,50,580,200);
str(vo:2,l);
settextstyle(smallfont,horizdir,4);
outtextxy(450,80,l) ;
outtextxy(310,80,'Kecepatan Awal       =  ');
outtextxy(480,80,'(m/s)');
str(uk:0:2,m);
settextstyle(smallfont,horizdir,4);
outtextxy(450,100,m) ;
outtextxy(310,100,'Koefisien Gesekan    = ');
str(t:2:2,p);
settextstyle(smallfont,horizdir,4);
outtextxy(450,120,p) ;
outtextxy(310,120,'Waktu                =  ');
outtextxy(486,120,'s');
str(x-100:2,r);
settextstyle(smallfont,horizdir,4);
outtextxy(450,140,r) ;
outtextxy(310,140,'Jarak                =  ');
outtextxy(486,140,'m');
outtextxy(120,305,'0');
outtextxy(170,305,'50');
outtextxy(220,305,'100');
outtextxy(270,305,'150');
outtextxy(320,305,'200');
outtextxy(370,305,'250');
outtextxy(420,305,'300');
outtextxy(470,305,'350');
outtextxy(520,305,'400');
outtextxy(570,305,'450');
outtextxy(620,305,'500');
line(0,300,120,300);
setcolor(blue);
line(120,300,640,300);
setcolor(red);
settextstyle(smallfont,horizdir,4);
setcolor(white);
outtextxy(10,320,'Permukaan Licin');
setcolor(red);
settextstyle(smallfont,horizdir,4);
outtextxy(300,320,'Permukaan Kasar');
{keterangan kecepatan awal}
str(vo:2,n);
settextstyle(smallfont,horizdir,4);
setcolor(yellow);
outtextxy(80,260,n) ;
outtextxy(10,260,'V Konstan = ');
outtextxy(100,260,'(m/s kuadrat)');
settextstyle(smallfont,horizdir,4);
setcolor(White);
outtextxy(310,240,'Benda Tidak Mengalami Gaya Gesekan (uk = 0)');
t:=t+0.05;
until x>=600;
end;
begin
if x>=600 then halt;
end;
if (x<=100)then
begin
t:=0;   xo:=100;
setcolor(10);
outtextxy(100,240,'Mengalami Perlambatan');
repeat
xs:=Xo+round(vo*(t)+(0.5)*(sqr(t))*(a));
delay(100);
cleardevice;
setcolor(white);
settextstyle(smallfont,horizdir,4);
rectangle(300,50,580,200);
str(vo:2,l);
settextstyle(smallfont,horizdir,4);
outtextxy(450,80,l) ;
outtextxy(310,80,'Kecepatan Awal       =  ');
outtextxy(480,80,'(m/s)');
str(uk:0:2,m);
settextstyle(smallfont,horizdir,4);
outtextxy(450,100,m) ;
outtextxy(310,100,'Koefisien Gesekan    = ');
str(t:2:2,p);
settextstyle(smallfont,horizdir,4);
outtextxy(450,120,p) ;
outtextxy(310,120,'Waktu                =  ');
outtextxy(486,120,'s');
str(xs-100:2,r);
settextstyle(smallfont,horizdir,4);
outtextxy(450,140,r) ;
outtextxy(310,140,'Jarak                =  ');
outtextxy(486,140,'m');
outtextxy(120,305,'0');
outtextxy(170,305,'50');
outtextxy(220,305,'100');
outtextxy(270,305,'150');
outtextxy(320,305,'200');
outtextxy(370,305,'250');
outtextxy(420,305,'300');
outtextxy(470,305,'350');
outtextxy(520,305,'400');
outtextxy(570,305,'450');
outtextxy(620,305,'500');
line(0,300,120,300);
setcolor(blue);
line(120,300,640,300);
setcolor(red);
settextstyle(smallfont,horizdir,4);
setcolor(white);
outtextxy(10,320,'Permukaan Licin');
setcolor(red);
settextstyle(smallfont,horizdir,4);
outtextxy(300,320,'Permukaan Kasar');
a:= (-uk*(g));
xo:=100;
setcolor(8);
rectangle(xs,286,xs+20,296);
line(20+xs,290,28+xs,294);
line(28+xs,294,28+xs,298);
line(20+xs,298,28+xs,298);
circle(4+xs,296,2);
circle(17+xs,296,2);
setfillstyle(solidfill,red);
floodfill(xs,295,8);
t:=t+0.05;
setcolor(white);
until t>(-vo/a );
end;
delay(100);
cleardevice;
setcolor(white);
settextstyle(smallfont,horizdir,4);
rectangle(300,50,580,200);
str(vo:2,l);
settextstyle(smallfont,horizdir,4);
outtextxy(450,80,l) ;
outtextxy(310,80,'Kecepatan Awal       =  ');
outtextxy(480,80,'(m/s)');
str(uk:0:2,m);
settextstyle(smallfont,horizdir,4);
outtextxy(450,100,m) ;
outtextxy(310,100,'Koefisien Gesekan    = ');
outtextxy(120,305,'0');
outtextxy(170,305,'50');
outtextxy(220,305,'100');
outtextxy(270,305,'150');
outtextxy(320,305,'200');
outtextxy(370,305,'250');
outtextxy(420,305,'300');
outtextxy(470,305,'350');
outtextxy(520,305,'400');
outtextxy(570,305,'450');
outtextxy(620,305,'500');
line(0,300,120,300);
setcolor(blue);
line(120,300,640,300);
setcolor(red);
settextstyle(smallfont,horizdir,4);
setcolor(white);
outtextxy(10,320,'Permukaan Licin');
setcolor(red);
settextstyle(smallfont,horizdir,4);
outtextxy(300,320,'Permukaan Kasar');
setcolor(8);
rectangle(xs,286,xs+20,296);
line(20+xs,290,28+xs,294);
line(28+xs,294,28+xs,298);
line(20+xs,298,28+xs,298);
circle(4+xs,296,2);
circle(17+xs,296,2);
setfillstyle(solidfill,red);
floodfill(xs,295,8);
setcolor(white) ;
str(t:2:2,o);
settextstyle(smallfont,horizdir,4);
outtextxy(450,120,o) ;
outtextxy(310,120,'Waktu                =  ');
outtextxy(486,120,'s');
str(xs-100:2,r);
settextstyle(smallfont,horizdir,4);
outtextxy(450,140,r) ;
outtextxy(310,140,'Jarak                =  ');
outtextxy(486,140,'m');
setcolor(white);
str(xs-100:2,k);
settextstyle(smallfont,horizdir,6);
outtextxy(365,350,k) ;
outtextxy(180,350,'Jarak Pengereman = ');
outtextxy(408,350,'(M)');
end;
begin
clrscr;
gotoxy(20,8) ;writeln('PROGRAM SIMULASI PENGEREMAN');
gotoxy(20,10);writeln('===========================================');
gotoxy(35,15);writeln('SILAHKAN INPUT');
gotoxy(20,20);write('Kecepatan Awal    (max = 30)     =  ');readln(vo);
gotoxy(20,25);write('Koefisien Gesekan                =  ');readln(uk);
animasi;
readln;
closegraph;
end.





