Kamis, 28 Juli 2011

Contoh Program Delphi Awal Semester 1

program Persegipanjang;

uses
Forms;

{$APPTYPE CONSOLE}
var
panjang,lebar,luas,keliling:integer;
begin
writeln('persegi panjang');
writeln('---------------');
writeln('panjang=');readln(panjang);
writeln('lebar=');readln(lebar);
luas:=panjang*lebar;
keliling:=(2*panjang)+(2*lebar);
writeln('luas=',luas);
writeln('keliling=',keliling);
readln
end.




program Rerata;

uses
Forms;

{$APPTYPE CONSOLE}

Var
a,b:string;
c:char;
d,f:integer;
g:real;

begin
write('nama=');readln(a);
write('kelas=');readln(b);
write('jenis kelamin=');readln(c);
write('nilai1=');readln(d);
write('nilai2=');readln(f);
g:=(d+f)/2;
writeln('nilai rerata=',g:8:2);
Readln;
end.





program lingkaran;

uses
Forms;

{$APPTYPE CONSOLE}
Const phi=3.14;
Var
a:integer;
b,c:real;

begin

writeln('lingkaran');
writeln('----------');
write('jari-jari=');readln(a);
b:=phi*a*a;
writeln('luas=',b:8:2);
c:=phi*2*a;
writeln('keliling=',c:8:2);
readln;
end.






program segitigasiku;

uses
Forms;

{$APPTYPE CONSOLE}
Var
a,b:integer;
c,d,e:real;

begin
writeln('segitiga siku-siku');
writeln('------------------');
write('alas=');readln(a);
write('tinggi=');readln(b);
c:=sqrt(sqr(a))+(sqr(b));
d:=a+b+c;
e:=(a*b)/2;
writeln('sisi miring=',c:8:2);
writeln('keliling=',d:8:2);
writeln('luas=',e:8:2);
readln;


end.

Tidak ada komentar:

Posting Komentar