Ejercicio
Dos números negativos
Objetivo
Cree un programa en Visual Basic para aceptar dos números del usuario y responder si ambos son negativos o no.
Código
' 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