Minggu, 08 April 2012

Jawaban Kuis No 1 Visual Basic


1. Buatlah Program menghitung penjualan buah, dengan input berupa:

  • Nama Buah (jeruk/apel/anggur) menggunakan COMBO BOX
  • Berat (kg)

Dengan output berupa:

  • Harga per KG
  • Total = berat * harga per kg
  • Diskon(%) = total * diskon
  • Total Bayar = total - diskon


Ketentuan Harga:

Buah

Harga Per Kg

Jeruk

10000

Apel

20000

Anggur

25000

Ketentuan Diskon:

Berat (Kg)

Diskon

0 – 5

0

6 – 10

5%

11 – 20

7.5%

>20

10%


Tampilan Program:













Codingnya :

Private Sub cmdHitung_Click()
If (cboBuah.Text = "Jeruk") Then
txtHarga.Text = 10000
ElseIf (cboBuah.Text = "Apel") Then
txtHarga.Text = 20000
ElseIf (cboBuah.Text = "Anggur") Then
txtHarga.Text = 25000
End If

If (txtBerat.Text <= 5) Then
txtDiskon.Text = 0
ElseIf (txtBerat.Text <= 10) Then
txtDiskon.Text = 0.05
ElseIf (txtBerat.Text <= 20) Then
txtDiskon.Text = 0.075
ElseIf (txtBerat.Text > 20) Then
txtDiskon.Text = 0.1
End If

txtTotal.Text = Val(txtHarga.Text) * Val(txtBerat.Text)

If (txtDiskon.Text = 0) Then
txtTotal_bayar.Text = txtTotal.Text
Else
txtDiskon.Text = Val(txtTotal.Text) * Val(txtDiskon.Text)
txtTotal_bayar.Text = Val(txtTotal.Text) - Val(txtDiskon.Text)
End If

End Sub

Private Sub cmdKeluar_Click()
End
End Sub

Private Sub cmdReset_Click()
cboBuah.Text = ""
txtBerat.Text = ""
txtHarga.Text = ""
txtTotal.Text = ""
txtDiskon.Text = ""
txtTotal_bayar.Text = ""
cboBuah.SetFocus
End Sub

Private Sub Form_Load()
cboBuah.AddItem "Jeruk"
cboBuah.AddItem "Apel"
cboBuah.AddItem "Anggur"
End Sub

Tidak ada komentar:

Posting Komentar