Exercise
Positive and negative
Objetive
Write a Visual Basic (VB.Net) program to get a number and answer whether it is positive or negative.
Code
' Import the System namespace to use Console class
Imports System
Public Class Program
' Main subroutine, entry point of the program
Public Shared Sub Main()
' Ask the user to input a number
Console.Write("Enter a number: ")
' Read the user's input and convert it to a double
Dim number As Double = Convert.ToDouble(Console.ReadLine())
' Check if the number is positive, negative, or zero
If number > 0 Then
' Display that the number is positive
Console.WriteLine("The number is positive.")
ElseIf number < 0 Then
' Display that the number is negative
Console.WriteLine("The number is negative.")
Else
' Display that the number is zero
Console.WriteLine("The number is zero.")
End If
End Sub
End Class