Design a VB.Net project that can be used to do all the arithmetic operations on
ID: 3626101 • Letter: D
Question
Design a VB.Net project that can be used to do all the arithmetic operations on two real numbers.Allow the user to enter two numbers in TextBoxes, and one of the arithmetic operators;+,-,*,/,,^,Mod in a smaller box provided for the operator. The user should click on a Button to have the operator perform its job.The logic for this project requres a chain of If/ElseIf statements to determine which operator is entered by the user, and to perform the required operations.Make sure not to perform division by zero if the second number entered is 0,and the operator is division.Add the following to this program.....
redo this program by adding a validation to the code.In this project, the user enters three input data: two operands and on arithmetic operator in provided TextBoxes. Validate eachh operand for being a number, and the operator for being one of the aritmetic operators in VB.NET:+-*/^ Mod.Notice that the operator validiation is a code check displaying and informative message, and setting the focus in the TextBox with incorrect data. This will allow the user to reenter the input and try again.
Explanation / Answer
In console application, source code
Imports System.Console
Module Module1
Sub Main()
Dim x, y, z As Integer
x = 30
y = 20
z = x + y
WriteLine("Addition" & " = " & z)
z = x - y
WriteLine("Subtraction" & " = " & z)
z = x * y
WriteLine("Multiplication" & " = " & z)
z = x / y
WriteLine("Division" & " = " & z)
Read()
End Sub
End Module
Concatenation Operators
Imports System.ConsoleModule Module1
Sub Main()
Dim str1, str2, str3, str4 As String
str1 = "Concatenation"
str2 = "Operators"
str3 = str1 + str2
WriteLine(str3)
str4 = str1 & str2
WriteLine(str4)
Read()
End Sub
End Module
The image below displays output from above code.
Comparison Operators
Imports System.ConsoleModule Module1
Sub Main()
Dim x, y As Integer
WriteLine("enter values for x and y ")
x = Val(ReadLine())
y = Val(ReadLine())
If x = y Then
WriteLine("x is equal to y")
ElseIf x < y Then
WriteLine("x is less than y")
ElseIf x > y Then
WriteLine("x is greater than y")
End If
Read()
End Sub
End Module
The image below displays output from above code.
Logical / Bitwise Operators
Imports System.ConsoleModule Module1
Sub Main()
Dim x As Boolean
x = Not 45 > 26
WriteLine("x not is false")
' x equals false
x = Not 26 > 87
' x equals True
WriteLine("x not is true")
Read()
End Sub
End Module
The image below displays output from above code.