Cara membuat Kalkulator Dengan Console


1. Buatlah project baru lalu pilih console, lalu masukkan coding dibawah ini.

Module Module1

Sub Main()
Console.Clear()
Console.WriteLine("Program Kalkulator Sederhana")
Console.WriteLine("--------------------------------------")


Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim d As Char

Console.Write("Bilangan 1 : ")
a = Console.ReadLine()
Console.WriteLine()
Console.Write("Operasi (+/-/*//): ")
d = Console.ReadLine
Console.WriteLine()
Console.Write("Bilangan 2 : ")
b = Console.ReadLine
Console.WriteLine()

Select Case UCase(d)
Case "+"
c = a + b
Console.WriteLine("Hasil: " & c & " ")
Case "-"
c = a - b
Console.WriteLine("Hasil: " & c & " ")
Case "*"
c = a * b
Console.WriteLine("Hasil: " & c & " ")
Case "/"
c = a / b
Console.WriteLine("Hasil: " & c & " ")
Case Else
Console.WriteLine("Anda Salah Memasukkan Tanda")
End Select

Console.WriteLine("-----------------------------------")
Repeater()

End Sub

Private Sub Repeater()
Dim pilih As Char

Console.Write("Mau Ulang(y/n)?")
pilih = Console.ReadLine()

If pilih = "y" Then
Main()
ElseIf pilih = "Y" Then
Main()
Else
Console.Write("Terima Kasih")
Console.ReadLine()

End If
End Sub
End Module

Tidak ada komentar:

Posting Komentar