Two negative numbers Learn programming Visual Basic (VB.net)



Lesson:

Flow Control


Exercise:

Two negative numbers


Objetive:

Create a Visual Basic (VB.net) program to prompt the user for two numbers and determine if both numbers are negative or not.


Code:

Imports System
Public Class exercise26
    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")
        If Not ((number1 < 0) AndAlso (number2 < 0)) Then Console.WriteLine("the numbers are NOT negative")
    End Sub
End Class



Juan A. Ripoll - Systems Tutorials and Programming Courses ©  All rights reserved.  Legal Conditions.