Ejercicio
Conversión
Objetivo
Cree un programa en Visual Basic para convertir de grados Celsius a Kelvin y Fahrenheit: le pedirá al usuario la cantidad de grados Celsius y utilizando las siguientes tablas de conversión:
Kelvin = Celsius + 273
Fahrenheit = Celsius x 18 / 10 + 32
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 temperature in Celsius
Console.Write("Enter the temperature in Celsius: ")
' Read the user's input and convert it to a double
Dim celsius As Double = Convert.ToDouble(Console.ReadLine())
' Convert Celsius to Kelvin using the formula
Dim kelvin As Double = celsius + 273
' Convert Celsius to Fahrenheit using the formula
Dim fahrenheit As Double = celsius * 1.8 + 32
' Display the equivalent temperature in Kelvin
Console.WriteLine("Temperature in Kelvin: " & kelvin)
' Display the equivalent temperature in Fahrenheit
Console.WriteLine("Temperature in Fahrenheit: " & fahrenheit)
End Sub
End Class