You are on page 1of 4

Imports System

'Logic Gate
'Write a program that will give the students the answer To logic gate questions
'For example:
'Enter logic gate : Or
'Enter first input : 1
'Enter second input : 0
'Result = 1
'It should work For the logic gates Or, And, Xor, NAND And NOR

Module Program

Sub Main(args As String())

Dim Input_1, Input_2, L_Gate As Integer

Console.WriteLine("LOGIC GATES")
Console.WriteLine("")

Console.WriteLine("1) AND GATE")


Console.WriteLine("2) NAND GATE")
Console.WriteLine("3) OR GATE")
Console.WriteLine("4) NOR GATE")
Console.WriteLine("5) NOT GATE")
Console.WriteLine("6) XOR GATE")
Console.WriteLine("")

Console.Write("Please Enter the number to choose the Logic Gate: ")


L_Gate = Console.ReadLine()

If L_Gate = 1 Then
'if 1 AND
Console.WriteLine("The LOGIC GATE selected is AND GATE.")
Console.WriteLine("")

Console.Write("Please Input 1: ")


Input_1 = Console.ReadLine()

Console.Write("Please Input 2: ")


Input_2 = Console.ReadLine()

If Input_1 And Input_2 = 1 Or 0 Then


GoTo correct
Else
Console.WriteLine("")
Console.WriteLine("Wrong Input! Please input either 1 or 0")
GoTo Tem
End If

correct:

If Input_1 And Input_2 = 1 Then


Console.WriteLine("")
Console.WriteLine("Output is 1")
Else
Console.WriteLine("")
Console.WriteLine("Output is 0")
End If
ElseIf L_Gate = 2 Then
'if 2 NAND
Console.WriteLine("The LOGIC GATE selected is NAND GATE.")
Console.WriteLine("")

Console.Write("Please Input 1: ")


Input_1 = Console.ReadLine()

Console.Write("Please Input 2: ")


Input_2 = Console.ReadLine()

If Input_1 And Input_2 = 1 Or 0 Then


GoTo correct1
Else
Console.WriteLine("")
Console.WriteLine("Wrong Input! Please input either 1 or 0")
GoTo Tem
End If

correct1:

If Input_1 And Input_2 = 1 Then


Console.WriteLine("")
Console.WriteLine("Output is 0")
Else
Console.WriteLine("")
Console.WriteLine("Output is 1")
End If

ElseIf L_Gate = 3 Then


'if 3 OR
Console.WriteLine("The LOGIC GATE selected is OR GATE.")
Console.WriteLine("")

Console.Write("Please Input 1: ")


Input_1 = Console.ReadLine()

Console.Write("Please Input 2: ")


Input_2 = Console.ReadLine()

If Input_1 And Input_2 = 1 Or 0 Then


GoTo correct2
Else
Console.WriteLine("")
Console.WriteLine("Wrong Input! Please input either 1 or 0")
GoTo Tem
End If

correct2:

If Input_1 Or Input_2 = 1 Then


Console.WriteLine("")
Console.WriteLine("Output is 1")
Else
Console.WriteLine("")
Console.WriteLine("Output is 0")
End If
ElseIf L_Gate = 4 Then
'if 4 NOR
Console.WriteLine("The LOGIC GATE selected is NOR GATE.")
Console.WriteLine("")

Console.Write("Please Input 1: ")


Input_1 = Console.ReadLine()

Console.Write("Please Input 2: ")


Input_2 = Console.ReadLine()

If Input_1 And Input_2 = 1 Or 0 Then


GoTo correct3
Else
Console.WriteLine("")
Console.WriteLine("Wrong Input! Please input either 1 or 0")
GoTo Tem
End If

correct3:

If Input_1 Or Input_2 = 1 Then


Console.WriteLine("")
Console.WriteLine("Output is 0")
Else
Console.WriteLine("")
Console.WriteLine("Output is 1")
End If

ElseIf L_Gate = 5 Then


'if 5 NOT
Console.WriteLine("The LOGIC GATE selected is NOT GATE.")
Console.WriteLine("")

Console.Write("Please Input 1: ")


Input_1 = Console.ReadLine()

If Input_1 = 1 Or 0 Then
GoTo correct3
Else
Console.WriteLine("")
Console.WriteLine("Wrong Input! Please input either 1 or 0")
GoTo Tem
End If

correct4:

If Input_1 = 1 Then
Console.WriteLine("")
Console.WriteLine("Output is 0")
Else
Console.WriteLine("")
Console.WriteLine("Output is 1")
End If

ElseIf L_Gate = 6 Then


'if 6 XOR
Console.WriteLine("The LOGIC GATE selected is XOR GATE.")
Console.WriteLine("")
Console.Write("Please Input 1: ")
Input_1 = Console.ReadLine()

Console.Write("Please Input 2: ")


Input_2 = Console.ReadLine()

If Input_1 And Input_2 = 1 Or 0 Then


GoTo correct5
Else
Console.WriteLine("")
Console.WriteLine("Wrong Input! Please input either 1 or 0")
GoTo Tem
End If

correct5:

If Input_1 = Input_2 Then


Console.WriteLine("")
Console.WriteLine("Output is 0")
Else
Console.WriteLine("")
Console.WriteLine("Output is 1")
End If

Else
Console.WriteLine("Wrong Option Selected...")
End If

Tem:

Console.ReadKey()

End Sub

End Module

You might also like