Pages

Tugas 2 Struktur Data

IF ELSE
var
a:integer;
begin
write('Berapa tinggi badanmu? [cm] ');
readln(a);
if (a>=100) and (a<=150) then
writeln('Anda Pendek')
else
if (a>=151) and (a<=169) then
writeln('Tinggi badan Ideal')
else
if (a>=170) and (a<=200) then
writeln('Anda Tinggi');
readln;
end.

var
a:integer;
begin
write('Berapa kali kamu membolos? ');
readln(a);
if a>=5 then
writeln('Kamu tidak boleh mengikuti ujian')
else
writeln('Silahkan persiapkan diri untuk ujian');
readln;
end.

var
a:string;
begin
write('Sudahkan anda belajar untuk ujian? [sudah/belum] ');
readln(a);
if a='sudah' then
writeln('segera istirahat')
else
writeln('belajarlah');
readln;
end.

CASE OF
var
a:integer;
begin
write('Tuliskan sebuah angka [1-10] ');
readln(a);
case a of
1:writeln('Satu');
2:writeln('Dua');
3:writeln('Tiga');
4:writeln('Empat');
5:writeln('Lima');
6:writeln('Enam');
7:writeln('Tujuh');
8:writeln('Delapan');
9:writeln('Sembilan');
10:writeln('Sepuluh');
end;
readln;
end.

var
a:integer;
begin
write('Berapa nilai Struktur Datamu?  ');
readln(a);
case a of
90..100:writeln('Baik Sekali');
80..89:writeln('Baik');
70..79:writeln('Cukup');
60..69:writeln('Belajarlah lagi');
0..59:writeln('Kamu tidak sungguh-sungguh');
end;
readln;
end.

var
a:integer;
begin
write('Berapa jam waktu internetmu?  ');
readln(a);
case a of
1:writeln('Tarif 3000');
2:writeln('Tarif 5000');
3:writeln('Tarif 7000');
end;
readln;
end.

FOR TO DO
var
x:integer;
begin
for x:=50 to 60 do
if (x<>51) and (x<>58)  then
writeln(x);
readln;
end.

var
x:integer;
begin
for x:=100 downto 90 do
if (x<>95) and (x<>91)  then
writeln(x);
readln;
end.

var
baris,kolom,jml:integer;
begin
write ('Jumlah Baris : ');
readln(jml);
for baris:=1 to jml do
begin
write ('#': jml);
for kolom := 2 to (2 *baris -1 ) do
begin
write('#');
end;
readln;
end;
end.

REPEAT UNTIL

var
x:integer;
begin
x:=2;
repeat
writeln(x);
x:=x+2;
until x=10;
readln;
end.

var
x:integer;
begin
x:=5;
repeat
writeln(x);
x:=x+5;
until x=30;
readln;
end.

var
x:integer;
begin
x:=10;
repeat
writeln(x);
x:=x+10;
until x>50;
readln;
end.

WHILE DO

var
x:integer;
begin
x:=3;
while(x<=18) do
begin
writeln(x);
x:=x+3;
end;
readln;
end.

var
x:integer;
begin
x:=5;
while(x<=30) do
begin
writeln(x);
x:=x+5;
end;
readln;
end.

var
x:integer;
begin
x:=2;
while(x<=12) do
begin
writeln(x);
x:=x+2;
end;
readln;
end.

Latihan 8 Sistem Basis Data



Text box harga
with thisform
.jumlah.value=val(.lama.value)*val(.harga.value)
Endwith
Diskon Umum
Diskon1
thisform.diskon.value=thisform.jumlah.value * .3
thisform.keterangan.value="Anda Mendapat Diskon"
thisform.bayar.value=thisform.jumlah.value - thisform.diskon.value

Diskon2
thisform.diskon.value=thisform.jumlah.value * .2
thisform.keterangan.value="Anda mendapat Diskon"
thisform.bayar.value=thisform.jumlah.value - thisform.diskon.value
Diskon3
thisform.diskon.value=thisform.jumlah.value * .1
thisform.keterangan.value="Anda Mendapat Diskon"
thisform.bayar.value=thisform.jumlah.value - thisform.diskon.value
Diskon4
thisform.diskon.value=thisform.jumlah.value * .0
thisform.keterangan.value="Tidak Dapat Diskon"
thisform.bayar.value=thisform.jumlah.value - thisform.diskon.value
Command Button Clear
thisform.lama.value=""
thisform.harga.value=""
thisform.jumlah.value=""
thisform.keterangan.value=""
thisform.diskon.value=""
thisform.bayar.value=""
thisform.lama.setfocus()
Command Button Selesai
thisform.release()

Hasil Run

Latihan 7 Sistem Basis Data



Command Button Proses
with thisform
                if .text1.value="VIP"
                .text3.value=val(.text2.value)*500000
                else
                if .text1.value="Kelas 1"
                .text3.value=val(.text2.value)*350000
                else
                if .text1.value="Kelas 2"
                .text3.value=val(.text2.value)*250000
                else
                .text3.value=val(.text2.value)*100000
endif
endif
endif

if val(.text2.value)>=10
.text4.value="10%"
.text5.value=val(.text3.text)-(val(.text3.text)*0.1)
else
if val(.text2.value)>=8
.text4.value="5%"
.text5.value=val(.text3.text)-(val(.text3.text)*0.05)
else
.text4.value="0%"
.text5.value=val(.text3.text)
endif
endif
Endwith
Command Button Clear
with thisform
.text1.value=""
.text2.value=""
.text3.value=""
.text4.value=""
.text5.value=""
Endwith
Command Button Exit
thisform.release()
Hasil Run

Latihan 3 Pemrograman Visual


procedure TForm1.RadioButton1Click(Sender: TObject);
var
a:real;
begin
a:=strtofloat(edit1.Text);
a:=1000;
edit1.Text:=floattostr(a);
edit4.text:=edit1.Text;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.Text:='0';
edit2.Text:='0';
edit3.Text:='0';
combobox1.Text:='';
combobox2.Text:='';
end;

procedure TForm1.RadioButton2Click(Sender: TObject);
var
a:real;
begin
a:=strtofloat(edit1.Text);
a:=1500;
edit1.Text:=floattostr(a);
edit4.text:=edit1.Text;
end;

procedure TForm1.RadioButton3Click(Sender: TObject);
var
a:real;
begin
a:=strtofloat(edit1.Text);
a:=2000;
edit1.Text:=floattostr(a);
edit4.text:=edit1.Text;
end;

procedure TForm1.ComboBox1Change(Sender: TObject);
var
b,q,w:real;
begin
q:=strtofloat(edit4.Text);
if combobox1.Text='Sate' then
    b:=20000;
if combobox1.Text='Gulai' then
    b:=15000;
if combobox1.Text='Tongseng' then
    b:=25000;
edit1.Text:=floattostr(b);
w:=q+b;
edit1.text:=floattostr(w);
edit5.text:=edit1.Text;
end;

procedure TForm1.ComboBox2Change(Sender: TObject);
var
c,r,t:real;
begin
r:=strtofloat(edit5.Text);
if combobox2.Text='Semangka' then
    c:=2000;
if combobox2.Text='Jeruk' then
    c:=1000;
if combobox2.Text='Nanas' then
    c:=1500;
edit1.Text:=floattostr(c);
t:=r+c;
edit1.Text:=floattostr(t);
edit6.text:=edit1.Text;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
x,y,z:real;
begin
x:=strtofloat(edit1.Text);
y:=strtofloat(edit2.Text);
z:=y-x;
if y<x then showmessage('Maaf Pembayaran Anda Kurang');
edit3.Text:=floattostr(z);
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
close;
end;

procedure TForm1.CheckBox1Click(Sender: TObject);
var
a,h,i:real;
begin
h:=strtofloat(edit6.Text);
a:=10000;
edit1.Text:=floattostr(a);
i:=h+a;
edit1.Text:=floattostr(i);
end;

procedure TForm1.RadioGroup1Click(Sender: TObject);
begin

end;

end.

Kisi-Kisi Bahasa Inggris TI 3 A

Silahkan download DISINI
download lagi HERE

Latihan 2 Pemrograman Visual



RadioGroup1
begin
case radiogroup1.ItemIndex of
0:begin
f:=1000;
end;
1:begin
f:=2000;
end;
2:begin
f:=3000;
end;
end;
edit1.Text:=floattostr(d+e+f);
end;

Combobox1
begin
case combobox1.ItemIndex of
0:begin
d:=1000;
end;
1:begin
d:=2000;
end;
2:begin
d:=3000;
end;
end;
edit1.Text:=floattostr(d+e+f);
end;

Combobox2
begin
case combobox2.ItemIndex of
0:begin
e:=1000;
end;
1:begin
e:=2000;
end;
2:begin
e:=3000;
end;
end;
edit1.Text:=floattostr(d+e+f);
end;

Button Mulai Baru
begin
combobox1.Text:='';
combobox2.Text:='';
edit1.Text:='';
edit2.Text:='';
edit3.Text:='';
end;

Button Hitung
var
a,b,c:real;
begin
a:=strtofloat(edit1.Text);
b:=strtofloat(edit2.Text);
c:=b-a;
if b<a then
showmessage('uang anda kurang');
edit3.Text:=floattostr(c);
end;

Button Exit
begin
form1.Close;
end;

Materi Komunikasi Data

Silahkan download DISINI

Tugas Mandiri Struktur Data

If_Else

var
a:integer;
begin
writeln('-----------------------------------');
writeln('     DAFTAR NILAI STRUKTUR DATA    ');
writeln('-----------------------------------');
write('Masukkan nilai anda: ');
readln(a);
if (a>=80) and (a<=100) then
writeln('Anda Pinter')
else
if (a>=60) and (a<=79) then
writeln('Rodo Pinter')
else
if (a>=0) and (a<=59) then
writeln('Kebangetan!!!')
else
writeln('Masukkan nilai dari 0 - 100 ');
readln;
end.
 


Case_Of


var
a:integer;
begin
writeln('------------------------------');
writeln(' DAFTAER NILAI STRUKTUR DATA  ');
writeln('------------------------------');
write('Masukkan nilai anda : ');
readln(a);
case a of
80..100:writeln('Pinter');
60..79:writeln('Rodo Pinter');
0..59:writeln('Kebangetan!!!');
end;
readln;
end.


For_To_Do

var
a:integer;
begin
for a:=25 to 30 do
writeln(a);
readln;
end.

Repeat_Until

var
a:integer;
begin
a:=25;
repeat
writeln(a);
a:=a+1;
until a=31;
readln;
end.


While_Do

var
a:integer;
begin
a:=24;
while (a<30) do
begin
a:=a+1;
writeln(a);
end;
readln;
end.




Latihan 1 Struktur Data

Latihan 1
var
 x:string;
 y:string[5];
begin
x:='struktur data';
y:='struktur data';
writeln(x);
writeln(y);
writeln(length(x));
writeln(length(y));
writeln(x+y);
readln;
end.

Latihan 2
var
x:integer;
begin
writeln('masukkan angka anda: ');
readln(x);
if(x<5) then
writeln('kurang dari 5')
else
writeln('lebih dari 5');
readln;
end.

Latihan 3
var
s:char;
begin
writeln('sudahkah anda berdoa hari ini? sudah(s)/belum(b)/akan(a)');
readln(s);
if (s='s') then
writeln('silahkan beraktifitas')
else
if (s='b') then
writeln('silahkan berdoa terlebih dahulu')
else
if (s='a') then
writeln('segeralah berdoa')
else
writeln('pilihan tidak ada');
readln;
end.

Latihan 4
var
s:char;
begin
writeln('sudahkah anda berdoa hari ini? sudah(s)/belum(b)/akan(a)');
readln(s);
case s of
's':writeln('silahkan beraktivitas');
'b':writeln('silahkan berdoa terlebih dahulu');
'a':writeln('segeralah berdoa');
else
writeln('pilihan tidak ada');
end;
readln;
end.

Latihan 5
var
x:integer;
begin
writeln('masukkan nilai: ');
readln(x);
case x of
90..100:writeln('A');
80..89:writeln('B');
70..79:writeln('C');
60..69:writeln('D');
else
writeln('pilihan tidak ada');
end;
readln;
end.

Latihan 6
var
x:integer;
begin
for x:=1 to 10 do
writeln(x);
readln;
end.

Latihan 7
var
x:integer;
begin
for x:=10 downto 1 do
writeln(x);
readln;
  { TODO -oUser -cConsole Main : Insert code here }
end.

Latihan 8
var
x:integer;
begin
x:=1;
repeat
writeln(x);
x:=x+1;
until x=10;
readln;
end.

Latihan 9
var
x:integer;
begin
x:=1;
while(x<=10) do
begin
writeln(x);
x:=x+1;
end;
readln;
end.