Ejercicio
El mayor de tres números
Objetivo
Escriba un programa en Visual Basic para obtener tres números del usuario y mostrar el mayor.
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()
' Ask the user to input the first number
Console.Write("Enter the first number: ")
' Read the user's input and convert it to a double
Dim firstNumber As Double = Convert.ToDouble(Console.ReadLine())
' Ask the user to input the second number
Console.Write("Enter the second number: ")
' Read the second number and convert it to a double
Dim secondNumber As Double = Convert.ToDouble(Console.ReadLine())
' Ask the user to input the third number
Console.Write("Enter the third number: ")
' Read the third number and convert it to a double
Dim thirdNumber As Double = Convert.ToDouble(Console.ReadLine())
' Determine the greatest number using conditional statements
Dim greatest As Double = firstNumber
If secondNumber > greatest Then
greatest = secondNumber
End If
If thirdNumber > greatest Then
greatest = thirdNumber
End If
' Display the greatest number
Console.WriteLine("The greatest number is: " & greatest)
End Sub
End Class