Greatest of three numbers Learn programming Visual Basic (


Flow Control


Greatest of three numbers


Write a Visual Basic ( program that prompts the user to enter three numbers and displays the greatest one.


Imports System
Public Class exercise19
    Public Shared Sub Main()
        Dim number1, number2, number3 As Integer
        Console.Write("Enter the number 1:")
        number1 = Convert.ToInt32(Console.ReadLine())
        Console.Write("Enter the number 2:")
        number2 = Convert.ToInt32(Console.ReadLine())
        Console.Write("Enter the number 3:")
        number3 = Convert.ToInt32(Console.ReadLine())

        If number1 > number2 AndAlso number1 > number3 Then
            Console.WriteLine("The number 1 is greatest")
        ElseIf number2 > number1 AndAlso number2 > number3 Then
            Console.WriteLine("The number 2 is greatest")
        ElseIf number3 > number1 AndAlso number3 > number2 Then
            Console.WriteLine("The number 3 is greatest")
            Console.WriteLine("Numbers equals")
        End If
    End Sub
End Class

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