study kasus 1 :
Bila nilai > 60 Hasil “Lulus”
Bila hasil < 60 hasil ”Tidak lulus”
SCRIPT VB
Private Sub Command1_Click()
If Text2.Text >= 60 Then
Text3.Text = "LULUS"
Else
Text3.Text = "TIDAK LULUS"
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Script pascal
program daftar_nilai;
uses wincrt;
var
nama : string;
nilai: integer;
begin
write ('nama:'); readln (nama);
write ('nilai:'); readln (nilai);
if nilai >= 60 then
writeln ('HASIL = LULUS')
else
writeln ('HASIL = TIDAK LULUS');
end.
end.
Input : Nama, Nilai
Proses
Jika nilai <= 55 hasil = “D”
Jika nilai <= 65 hasil = “C”
Jika nilai <= 75 hasil = “B”
Jika nilai > 75 hasil = “A”
Cetak : Nama, Nilai, Hasil
Script Vb
Private Sub Command1_Click()
If Text2 <= 55 Then
Text3.Text = "D"
Else
If Text2 <= 65 Then
Text3.Text = "C"
Else
If Text2 <= 75 Then
Text3.Text = "B"
Else
Text3.Text = "A"
End If
End If
End If
End Sub
Private Sub Command2_Click()
MsgBox "Terima kasih daa....!!!!!"
End
End Sub
Scipt Pascal
program latihan2;
uses wincrt;
var
Nama :string;
NIlai :integer;
begin
write('Nama : ');readln(Nama);
writeln;
write('Nilai : ');readln(nilai);
writeln;
if (nilai) <= 55 then
writeln('Hasil : D')
else
if (nilai) <= 65 then
writeln('Hasil : B')
else
if (nilai) <= 75 then
writeln('Hasil : B')
else
writeln('Hasil : A');
end.
end.
Lat 3:
Studi Kasus
Proses : Jika Nilai ≥85 dan ≤ 100; hasil = “A”
Jika Nilai ≥75 dan ≤ 84; hasil = “B”
Jika Nilai ≥60 dan ≤ 74; hasil = “C”
Jika Nilai ≥50 dan ≤ 59; hasil = “D”
Jika Nilai ≥1 dan ≤ 49; hasil = “E”
Private Sub Command2_Click()
MsgBox ("MATUR SUWUN")
Unload Me
End Sub
Private Sub Command1_Click()
If Text2 <= 100 And Text2 >= 85 Then
Text3.Text = "A"
Else
If Text2 <= 84 And Text2 >= 75 Then
Text3.Text = "B"
Else
If Text2 <= 75 And Text2 >= 60 Then
Text3.Text = "C"
Else
If Text2 <= 59 And Text2 >= 50 Then
Text3.Text = "D"
Else
Text3.Text = "E"
End If
End If
End If
End If
End Sub
Script pascal :
program data_nilai;
uses wincrt;
var
nama,grade : string;
nilai: integer;
begin
write ('nama:'); readln (nama);
write ('nilai:'); readln (nilai);
If (nilai <= 100) And (nilai >= 85) Then
writeln ('grade = A')
else
If (nilai <= 84) And (nilai >= 75) Then
writeln ('grade = B')
else
If (nilai <= 75) And (nilai >= 60) Then
writeln ('grade = C')
else
If (nilai <= 59) And (nilai >= 50) Then
writeln ('grade = D')
Else
writeln ('grade = E')
end.
end.
Study kasus 4 :
Mencari Luas Segitiga, Luas segiempat, dan Luas Lingkaran
Private Sub clear_Click()
Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
Text5 = ""
Text6 = ""
End Sub
Private Sub exit_Click()
MsgBox ("MATUR TENKYU")
Unload Me
End Sub
Private Sub proses_Click()
Text4 = Val(Text1 * Text2) * 0.5
Text5 = Val(Text1 * Text2)
Text6 = Val(Text3 * Text3) * 3.14
End Sub
Script Pascal :
program lat;
uses wincrt;
var Pj:Byte;
Lb:Byte;
Jr:Byte;
Luas3:Real;
Luas4:Byte;
Luaslkr:Real;
Begin
Write('Panjang:');Readln(Pj);
Write('Lebar:');Readln(Lb);
Write('Jari-jari:');Readln(Jr);
Luas3:=(Pj*Lb)*0.5;
Luas4:=(Pj*Lb);
Luaslkr:=(Jr*Jr)*3.14;
Writeln('Luas Segitiga=',Luas3,6:2);
Writeln('Luas segiempat=',Luas4);
Writeln('Luas lingkaran=',Luaslkr,6:2);
Writeln('>>>>>Copyright @2010 by Hotaru 'Ansy Dianzou<<<<<');
writeln('>>>>>>>>http://www.ryocorner.co.cc<<<<<<<<');
End.
End
v Input kode bunga, jumlah bunga
v Kondisi jika kode bunga = “ml”; nama bunga = “Melati”; harga = 40,000
v Kondisi jika kode bunga = “mw”; nama bunga = “Mawar”; harga = 50,000
v Kondisi jika kode bunga = “an”; nama bunga = “Anggrek”; harga = 75,000
v Kondisi jika jumlah bunga ≤ 3; discount = 0
v Kondisi jika jumlah bunga ≤ 6; discount = 5,000
v Kondisi jika jumlah bunga > 6; discount = 10,000
v Proses bayar = (jumlah bunga x harga) – discount
Cetak kode bunga, nama bunga, jumlah bunga, harga dan bayarIf Text1 = "ml" Then
Text3.Text = "Melati"
Text4 = 40000
Else
If Text1 = "mw" Then
Text3.Text = "Mawar"
Text4 = 50000
Else
If Text1 = "an" Then
Text3.Text = "Anggrek"
Text4.Text = 75000
Else
Text3.Text = "kosong"
Text4 = 0
Exit Sub
End If
End If
End If
If Text2 <= 3 Then
Text5 = 0
Else
If Text2 <= 6 Then
Text5 = 5000
Else
Text5 = 10000
End If
End If
Text6 = (Text2 * Text4) - Text5
End Sub
Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
End Sub
Private Sub Command3_Click()
MsgBox ("tengkiyuuuuuuuuuuuuuut...........")
End
End Sub
uses wincrt;
var
kode, nama : string;
jmlh, hrg, disc, byr : Real;
Begin
write('Kode Bunga = '); readln(kode);
write('Jumlah Bunga = '); readln(jmlh);
writeln;
if (kode) = 'ml' then writeln('Nama Bunga = Melati Harga Bunga = 40000')
else
if (kode) = 'mw' then writeln('Nama Bunga = Mawar Harga Bunga = 50000')
else
if (kode) = 'an' then writeln('Nama Bunga = Anggrek Harga Bunga = 75000');
if (kode) = 'ml' then hrg:=40000
else
if (kode) = 'mw' then hrg:=50000
else
if (kode) = 'an' then hrg:=75000;
writeln;
if jmlh <=3 then writeln('Discount = 0')
else
if jmlh <=6 then writeln('Discount = 5000')
else
writeln('Discount = 10000');
if jmlh <=3 then disc:=0
else
if jmlh <=6 then disc:=5000
else
disc:=10000;
byr:=(jmlh*hrg)-disc;
writeln;
writeln('Bayar = Rp ',byr:6:2);
end.
end.
Tidak ada komentar:
Posting Komentar