One or two negative numbers Learn programming with Visual Basic ( exercises


Flow Control


One or two negative numbers 96


Create a Visual Basic ( program to prompt the user for two numbers and determine whether both are negative, only one is negative, or neither is negative.


Imports System
Public Class Exercise27
    Public Shared Sub Main()
        Dim number1 As Integer
        Dim number2 As Integer
        Console.Write("number 1: ")
        number1 = Convert.ToInt32(Console.ReadLine())
        Console.Write("number 2: ")
        number2 = Convert.ToInt32(Console.ReadLine())

        If (number1 < 0) AndAlso (number2 < 0) Then
            Console.WriteLine("the numbers are negative")
        ElseIf (number1 < 0) OrElse (number2 < 0) Then
            Console.WriteLine("one is negative")
            Console.WriteLine("none is negative")
        End If
    End Sub
End Class