Today I am going to Show a Simple Calculator using VB.Net .
Write a program to develop a calculator using select
case.
Write a program to develop a calculator using select
case.
*(Select case work Same as Switch case)
Module Module1
Sub Main()
Dim a, b, c, ch As Integer // Declaration a,b,c,ch variable Integer type
Console.WriteLine("Enter
the two numbers")
a = Integer.Parse(Console.ReadLine()) //Taking first number from user
b = Integer.Parse(Console.ReadLine()) //Taking second number from user
Console.WriteLine("CALCULATOR")
/* Showing output To User
Console.WriteLine("1.ADDITION")
Console.WriteLine("2.SUBTRACTION")
Console.WriteLine("3.MULTIPLICATION")
Console.WriteLine("4.DIVISION")
Console.WriteLine("Enter
your choice(1-4)") */
ch = Integer.Parse(Console.ReadLine()) //Taking value from user to select an option
Select Case ch //select case work same as Switch
Case 1
c = a + b
Console.WriteLine("Addition of {0} and {1} is {2}", a, b,
c)
Case 2
c = a - b
Console.WriteLine("subtraction of {0} and {1} is {2}", a,
b, c)
Case 3
c = a * b
Console.WriteLine("Multiplication of {0} and {1} is {2}",
a, b, c)
Case 4
Console.WriteLine("division of {0} and {1} is {2}", a, b,
c) /*{0},{1},{2} defines the position of variable here {0} points 'a' , {1} points 'b' and {3} points 'c' */
Case Else
Console.WriteLine("INVALID CHOICE")
End Select
Console.Read()
End Sub
End Module
**WHOLE PROGRAM IN VB.NET DOES'T CONTAIN TERMINATOR ";"