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

TUGAS

This document contains code snippets from several programs written by Yehezkiel Graham Simorangkir. The first program is a simple shopping cart program that calculates total, discount, and bonus items based on purchase amount. The second program allows ordering food and drinks and calculates the total cost. The third program uses branching (if/else statements) to calculate a grade based on scores in different subjects and provide a description for the grade. The document also includes an explanation of some key concepts in the code like data types, else if statements, and if statements.

Uploaded by

Aguromo Nanto
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)
43 views6 pages

TUGAS

This document contains code snippets from several programs written by Yehezkiel Graham Simorangkir. The first program is a simple shopping cart program that calculates total, discount, and bonus items based on purchase amount. The second program allows ordering food and drinks and calculates the total cost. The third program uses branching (if/else statements) to calculate a grade based on scores in different subjects and provide a description for the grade. The document also includes an explanation of some key concepts in the code like data types, else if statements, and if statements.

Uploaded by

Aguromo Nanto
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 : Yehezkiel Graham Simorangkir

Kelas : 20S02
Nim : 2002092

 Program Belanja Sederhana


- Code :
Public Class Form1
Private Sub Button2_Click(ByVal sender As System.Object, ByVal
e As
System.EventArgs) Handles Button2.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
TextBox1.Focus()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal
e As
System.EventArgs) Handles Button1.Click
'Deklarasi Variabel
Dim Harga, Jumlah As Integer
Dim Total, Diskon, Bayar As Double
Dim Bonus As String
'Input harga dan jumlah
Harga = TextBox2.Text
Jumlah = TextBox3.Text
Total = Harga * Jumlah
If Total >= 500000 Then
Diskon = 0.2 * Total
Bonus = "Tas Pinggang"
ElseIf Total >= 200000 Then
Diskon = 0.15 * Total
Bonus = "Payung"
ElseIf Total >= 100000 Then
Diskon = 0.1 * Total
Bonus = "Kaos"
ElseIf Total >= 50000 Then
Diskon = 0.05 * Total
Bonus = "Pena"
Else
Diskon = 0
Bonus = "Tidak Ada "
End If
Bayar = Total - Diskon
TextBox4.Text = Total
TextBox5.Text = Diskon
TextBox6.Text = Bayar
TextBox7.Text = Bonus
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal
e As
System.EventArgs) Handles Button3.Click
End
End Sub
End Class

Hasil:

 Order Makanan
- Code
Public Class Form2
Public hgmkn, hgmnm As Integer
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e
As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Select Case ComboBox1.Text
Case "Nasi Uduk"
Label3.Text = "Rp. 3500"
hgmkn = 3500
Case "Bakso"
Label3.Text = "Rp. 6000"
hgmkn = 6000
Case "Mie Ayam"
Label3.Text = "Rp. 7000"
hgmkn = 7000
End Select
End Sub
Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e
As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
Select Case ComboBox2.Text
Case "Es Jeruk"
Label4.Text = "Rp. 3000"
hgmnm = 3000
Case "Jus Alpukat"
Label4.Text = "Rp. 7000"
hgmnm = 7000
Case "Teh Manis"
Label4.Text = "Rp. 4000"
hgmnm = 4000
End Select
End Sub
Public Sub New()
' This call is required by the designer.
InitializeComponent()
ComboBox2.Visible = False
Label4.Visible = False
' Add any initialization after the InitializeComponent() call.
End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Enabled = False Then
ComboBox2.Visible = False
End If
If CheckBox1.Enabled = True Then
ComboBox2.Visible = True
Label4.Visible = True
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal
e As
System.EventArgs) Handles Button1.Click
Dim porsimkn, porsimnm, jlh As Integer
porsimkn = TextBox1.Text
porsimnm = TextBox2.Text
jlh = (hgmkn * porsimkn) + (hgmnm * porsimnm)
Label7.Text = "Rp. " & jlh.ToString
End Sub
End Class
- Hasil :
 Percabangan
- Code
Public Class Form3
Dim NA As Double
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e
As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
End Sub
Private Sub TextBox3_TextChanged(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles TextBox3.TextChanged
TextBox8.Text = (0.1 * Val(TextBox3.Text)) + (0.15 *
Val(TextBox4.Text)) +
(0.15 * Val(TextBox5.Text)) + (0.25 * Val(TextBox6.Text)) +
(0.35 *
Val(TextBox7.Text))
End Sub
Private Sub TextBox4_TextChanged(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles TextBox4.TextChanged
TextBox8.Text = (0.1 * Val(TextBox3.Text)) + (0.15 *
Val(TextBox4.Text)) +
(0.15 * Val(TextBox5.Text)) + (0.25 * Val(TextBox6.Text)) +
(0.35 *
Val(TextBox7.Text))
End Sub
Private Sub TextBox5_TextChanged(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles TextBox5.TextChanged
TextBox8.Text = (0.1 * Val(TextBox3.Text)) + (0.15 *
Val(TextBox4.Text)) +
(0.15 * Val(TextBox5.Text)) + (0.25 * Val(TextBox6.Text)) +
(0.35 *
Val(TextBox7.Text))
End Sub
Private Sub TextBox6_TextChanged(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles TextBox6.TextChanged
TextBox8.Text = (0.1 * Val(TextBox3.Text)) + (0.15 *
Val(TextBox4.Text)) +
(0.15 * Val(TextBox5.Text)) + (0.25 * Val(TextBox6.Text)) +
(0.35 *
Val(TextBox7.Text))
End Sub
Private Sub TextBox7_TextChanged(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles TextBox7.TextChanged
TextBox8.Text = (0.1 * Val(TextBox3.Text)) + (0.15 *
Val(TextBox4.Text)) +
(0.15 * Val(TextBox5.Text)) + (0.25 * Val(TextBox6.Text)) +
(0.35 *
Val(TextBox7.Text))
End Sub
Private Sub TextBox8_TextChanged(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles TextBox8.TextChanged
If TextBox8.Text > 80 Then
TextBox9.Text = "A"
ElseIf TextBox8.Text >= 70 Then
TextBox9.Text = "B"
ElseIf TextBox8.Text >= 60 Then
TextBox9.Text = "C"
ElseIf TextBox8.Text >= 50 Then
TextBox9.Text = "D"
Else
TextBox9.Text = "E"
End If
End Sub
Private Sub TextBox9_TextChanged(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles TextBox9.TextChanged
Select Case TextBox9.Text
Case "A"
TextBox1.Text = "Sangat Memuaskan"
Case "B"
TextBox1.Text = "Memuaskan"
Case "C"
TextBox1.Text = "Cukup"
Case "D"
TextBox1.Text = "Kurang"
End Select
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles TextBox1.TextChanged
End Sub
End Class
- Hasil :

 Penjelasan Code:
- Pernyataan DIM menyatakan berbagai jenis variabel dalam BASIC atau VBA. Ini termasuk
bilangan bulat (byte, integer atau panjang), angka floating-point (tunggal atau ganda), string
(alfanumerik), mata uang, tanggal, Boolean dan objek.
- Double merupakan versi presisi ganda dari tipe data Foat. Jika kamu menghitung jumlah
yang besar, maka tingkat keakuratan lebih besar dengan ketepatan yang tinggi di dalam
Double.
- Fungsi Else If merupakan Percabangan dalam pemrograman adalah proses penentuan
keputusan atau disebut dengan conditional statement. Pada dasarnya konsep percabangan
untuk memerintahkan komputer melakukan suatu aksi tertentu berdasarkan kondisi yang
terpenuhi atau tidak terpenuhi.
- IF adalah salah satu pernyataan penyeleksian yang memungkinkan kita memanipulasi
aliran
jalannya program berdasarkan conditional expression. Hal ini dapat memungkinkan kita
membuat program yang berjalan secara fleksibel sesuai keadaan dari pengguna dan mesin.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy