0% found this document useful (0 votes)
40 views6 pages

Rancangan Algoritma Dan Program Struktur Kontrol Percabangan 1. If-Then Algoritma: If (A Rabu) Then B Pemograman Visual End If Program

This document discusses algorithms and Visual Basic programs for control flow structures including if-then, if-then-else, nested if, and select case. It provides examples of algorithms and code for each type of control structure. The if-then examples check day of week and return class assignments. If-then-else examples check exam scores and return letter grades. Nested if examples check train class and destination to return ticket prices. Finally, select case examples check month number and return corresponding names.

Uploaded by

Tita Rositaa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views6 pages

Rancangan Algoritma Dan Program Struktur Kontrol Percabangan 1. If-Then Algoritma: If (A Rabu) Then B Pemograman Visual End If Program

This document discusses algorithms and Visual Basic programs for control flow structures including if-then, if-then-else, nested if, and select case. It provides examples of algorithms and code for each type of control structure. The if-then examples check day of week and return class assignments. If-then-else examples check exam scores and return letter grades. Nested if examples check train class and destination to return ticket prices. Finally, select case examples check month number and return corresponding names.

Uploaded by

Tita Rositaa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Nama : Yudha Kusmana

NPM : 1441177004106
Kelas : 6H
tugas Pemrograman Visual

Rancangan Algoritma dan Program struktur kontrol percabangan


1. If-Then
 Algoritma :
if (a>Rabu) then
b=Pemograman Visual
end if

Program

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
If Combo1.Text = "Senin" Then
MsgBox("Studi literatur")
End If
If Combo1.Text = "Selasa" Then
MsgBox("Manajemen proyek")
End If
If Combo1.Text = "Rabu" Then
MsgBox("Pemograman Visual")
End If
If Combo1.Text = "Kamis" Then
MsgBox("Pemograman Android")
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
Combo1.Items.Add("Senin")
Combo1.Items.Add("Selasa")
Combo1.Items.Add("Rabu")
Combo1.Items.Add("Kamis")
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
Form2.Show()
Hide()
End Sub

Private Sub Combo1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Combo1.SelectedIndexChanged

End Sub
End Class
2. If-Then-Else

 Algoritma

If  (kondisi)  Then


(pernyataan)
...
(pernyataan)
Else
(pernyataan)
...
(pernyataan)
End If

 Program

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
Dim nilai As Integer
nilai = TextBox1.Text()
If (nilai < 60) Then
TextBox2.Text = "Grade nilai anda = E"
End If
If (nilai >= 60) And (nilai < 70) Then
TextBox2.Text = "Grade nilai anda = D"
End If
If (nilai >= 70) And (nilai < 80) Then
TextBox2.Text = "Grade nilai anda = C"
End If
If (nilai >= 80) And (nilai < 90) Then
TextBox2.Text = "Grade nilai anda = B"
End If
If (nilai >= 90) And (nilai <= 100) Then
TextBox2.Text = "Grade nilai anda = A"
End If
End Sub
End Class

3. If-Majemuk

Public Class Form3

Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles MyBase.Load
isimaskereta()
isitujuan()
End Sub
Sub isikereta()
maskapai.Items.Add("Kelas a")
maskapai.Items.Add("Kelas b")
maskapai.Items.Add("Kelas c")
End Sub

Sub isitujuan()
tujuan.Items.Add("Karawang-Jakarta")
tujuan.Items.Add("Bandung-Jakarta")
tujuan.Items.Add("Karawang-Semarang")
End Sub

Private Sub tujuan_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles tujuan.SelectedIndexChanged
If Kereta.Text = "Kelas a" Then
If tujuan.Text = "Karawang-Jakarta" Then
harga.Text = 50000
ElseIf tujuan.Text = "Bandung-Jakarta" Then
harga.Text = 80000
ElseIf tujuan.Text = "Karawang-Semarang" Then
harga.Text = 1000000
End If
ElseIf maskapai.Text = "Kelas b" Then
If tujuan.Text = "Karawang-Jakarta" Then
harga.Text = 30000
ElseIf tujuan.Text = "Bandung-Jakarta" Then
harga.Text = 500000
ElseIf tujuan.Text = "Karawang-Semarang" Then
harga.Text = 70000
End If
ElseIf maskapai.Text = "Kelas c" Then
If tujuan.Text = "Karawang-Jakarta" Then
harga.Text = 10000
ElseIf tujuan.Text = "Bandung-Jakarta" Then
harga.Text = 30000
ElseIf tujuan.Text = "Karawang-Semarang" Then
harga.Text = 40000
End If
End If
End Sub

Private Sub Kerea_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles maskapai.SelectedIndexChanged

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
Form2.Show()
Close()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
Form4.Show()
Hide()
End Sub

Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Label1.Click

End Sub
End Class
4. Select-Case

 Algoritma

Select Case (kondisi)


Case (ekspresi-1)
(pernyataan-1)
...
(pernyataan-1)
Case (ekspresi-2)
(pernyataan-2)
...
(pernyataan-2)
Case else
(pernyataan –n)
End Select

Program
Public Class Form4

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
Dim bulan As String
Dim no_anak As Integer

bulan = TextBox2.Text
no_anak = TextBox1.Text
Select Case no_anak
Case 1
bulan = "Yudha Kusmana"
Case 2
bulan = "Nenden Kusmawati"
Case 3
bulan = "Agustin Puspita"
Case 4
bulan = "Fathur rohman"
Case 5
bulan = "Faisal Hambali"
Case 6
bulan = "James"
Case 7
bulan = "Rey masterio"
Case 8
bulan = "Ronaldo"
Case 9
bulan = "Rudi"
Case 10
bulan = "Yatt skatepunk"
Case 11
bulan = "Satim"
Case 12
bulan = "Petet"
Case Else
MsgBox("Jumlah bulan hanya ada 12, tolong input ulang")
End Select
TextBox2.Text = bulan

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
Form3.Show()
Close()
End Sub

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles TextBox1.TextChanged

End Sub

Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles TextBox2.TextChanged

End Sub
End Class

You might also like