Exercise
Two negative numbers
Objetive
Write a Visual Basic (VB.Net) program to prompt the user for two numbers and determine if both numbers are negative or not.
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()
' Declare variables to store the two numbers entered by the user
Dim num1 As Integer
Dim num2 As Integer
' Prompt the user to enter the first number
Console.Write("Enter the first number: ")
num1 = Integer.Parse(Console.ReadLine())
' Prompt the user to enter the second number
Console.Write("Enter the second number: ")
num2 = Integer.Parse(Console.ReadLine())
' Check if both numbers are negative
If num1 < 0 AndAlso num2 < 0 Then
' If both numbers are negative, display this message
Console.WriteLine("Both numbers are negative.")
Else
' If either or both numbers are not negative, display this message
Console.WriteLine("Both numbers are not negative.")
End If
End Sub
End Class