Conditional and boolean Learn programming Visual Basic (VB.net)

Lesson:

Basic Data Types


Exercise:

Conditional and boolean 14


Objetive:

Create a Visual Basic (VB.net) program that uses the conditional operator to give a boolean variable named "bothEven" the value "true" if two numbers entered by the user are the even, or "false" if any of them is odd.


Code:

Imports System
Public Class Exercise70
    Public Shared Sub Main()
        Dim num1, num2 As Integer
        Dim bothEven As Boolean
        Console.Write("Enter First number: ")
        num1 = Convert.ToInt32(Console.ReadLine())
        Console.Write("Enter Second number: ")
        num2 = Convert.ToInt32(Console.ReadLine())
        bothEven = If(((num1 Mod 2 = 0) AndAlso (num2 Mod 2 = 0)), True, False)
        Console.WriteLine(If(bothEven, "there're numbers bothEven", "there's a number odd"))
    End Sub
End Class