Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Hi I am Writing a calculator in Visual basics and there seems to be a Error occurring.

+3 votes
asked Sep 9 by Ibrahim Ahmad (150 points)
Dim a,b,c As Integer
Dim op As String
Console.Writeline("Calculater")
    Console.Write ("Enter first number")
a=Console.Readline
    Console.write ("Enter second numbers")
b=Console.Readline
    Console.Write ("Enter Operator")
op=Console.Readline
If op = "t" Then
    c = a+b
ElseIf op = "-" Then
    c = a-b
ElseIf op = "*" Then
    c = a*b
ElseIf op = "/" Then
    c = a/b
ElseIf
     Console.WriteLine ("Invalid op")
End If
     Console.Write ("Answer="&c)
End Sub

1 Answer

0 votes
answered Sep 10 by Twisha Bose (140 points)
Dim a, b, c As Integer
Dim op As String

Console.WriteLine("Calculator")
Console.Write("Enter first number: ")
a = Convert.ToInt32(Console.ReadLine())

Console.Write("Enter second number: ")
b = Convert.ToInt32(Console.ReadLine())

Console.Write("Enter Operator: ")
op = Console.ReadLine()

If op = "+" Then
    c = a + b
ElseIf op = "-" Then
    c = a - b
ElseIf op = "*" Then
    c = a * b
ElseIf op = "/" Then
    If b = 0 Then
        Console.WriteLine("Division by zero is not allowed")
    Else
        c = a / b
    End If
Else
    Console.WriteLine("Invalid operator")
End If

Console.WriteLine("Answer = " & c)
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...