Belajar Console Application Visual Basic 2,,,


Berikut contoh console aplication dari hasil uts algoritma semester ini,,
Semoga bermanfaat,,
Module Module2
    Sub Main()
        Dim nama, npm, kelas As String
        Dim panjang, lebar, luas, rata, diskon, jmlx, hargabayar, jumlahbrg As Double
        Dim nomor, i, n, x, kodebrg, harga As Integer

        Console.WriteLine("Made By Arif Zulfahri")
        Console.WriteLine("NPM 6104039")
        Console.WriteLine("I_B Logistik Bisnis D-4")
        Console.WriteLine()

        Console.Write("Nama    : ")
        nama = Console.ReadLine
        Console.Write("NPM     : ")
        npm = Console.ReadLine
        Console.Write("Kelas   : ")
        kelas = Console.ReadLine
        Console.WriteLine()

        Console.Write("Nama    : ")
        Console.WriteLine(nama)
        Console.Write("NPM     : ")
        Console.WriteLine(npm)
        Console.Write("Kelas   : ")
        Console.WriteLine(kelas)
        Console.WriteLine("Silahkan Pilih Perhitungan Rumus-rumus berikut:")
        Console.WriteLine("    1. Luas Segi Empat")
        Console.WriteLine("    2. Perhitungan Rata-rata X")
        Console.WriteLine("    3. Perhitungan Diskon Pembelian")

        Console.Write("Nomor yang dipilih? ")
        nomor = Console.ReadLine
        Console.WriteLine()

        Select Case nomor
            Case 1
                Console.WriteLine("Perhitungan Luas Segi Empat")
                Console.Write("Panjang : ")
                panjang = Console.ReadLine
                Console.Write("Lebar : ")
                lebar = Console.ReadLine
                Console.Write("Luas Segiempat adalah : ")
                luas = panjang * lebar
                Console.WriteLine(luas)
            Case 2
                Console.WriteLine("Perhitungan Rata-Rata X")
                Console.Write("Masukan Jumlah Data : ")
                n = Console.ReadLine
                For i = 1 To n
                    Console.Write("Data ke " + CStr(i) + " : ")
                    x = Console.ReadLine
                    jmlx = jmlx + x
                Next
                rata = jmlx / n
                Console.Write("Rata-rata x adalah  : ")
                Console.WriteLine(rata)
            Case 3
                Console.WriteLine("Perhitungan Diskon")
                Console.WriteLine("Pilih Angka Kode Barang : 1/2/3 ?")
                Console.Write("Kode Barang  : ")
                kodebrg = Console.ReadLine
                Console.Write("Jumlah       : ")
                jumlahbrg = Console.ReadLine

                Console.Write("Harga Barang : ")
                If kodebrg = 1 Then
                    Console.WriteLine("Rp. 20.000")
                    harga = 20000
                ElseIf kodebrg = 2 Then
                    Console.WriteLine("Rp. 50.000")
                    harga = 50000
                ElseIf kodebrg = 3 Then
                    Console.WriteLine("Rp. 75.000")
                    harga = 75000
                End If

                Console.Write("Diskon       : ")
                If jumlahbrg < 100 Then
                    Console.WriteLine("5%")
                    diskon = (5 / 100) * harga * jumlahbrg
                ElseIf jumlahbrg >= 100 And jumlahbrg <= 150 Then
                    Console.WriteLine("10%")
                    diskon = (10 / 100) * harga * jumlahbrg
                ElseIf jumlahbrg > 150 Then
                    Console.WriteLine("15%")
                    diskon = (15 / 100) * harga * jumlahbrg
                End If

                hargabayar = (harga * jumlahbrg) - diskon

                Console.Write("Harga dibayar: Rp.")
                Console.WriteLine(hargabayar)
        End Select
        Console.ReadKey()
    End Sub
End Module

Posted on 12 Mei 2011, in Tugas Mata Kuliah. Bookmark the permalink. Tinggalkan komentar.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: