Ejercicio
Operaciones equivalentes
Objetivo
Escribe un programa en Visual Basic para pedir al usuario tres números (a, b, c) y mostrar el resultado de (a+b)·c y el resultado de a·c + b·c
Código
' Import the System namespace to use Console classImports System
Public Class Program
' Main subroutine, entry point of the program
Public Shared Sub Main()
' Prompt the user to enter the first number (a)
Console.Write("Enter the first number (a): ")
' Read the user's input and convert it to a double
Dim a As Double = Convert.ToDouble(Console.ReadLine())
' Prompt the user to enter the second number (b)
Console.Write("Enter the second number (b): ")
' Read the user's input and convert it to a double
Dim b As Double = Convert.ToDouble(Console.ReadLine())
' Prompt the user to enter the third number (c)
Console.Write("Enter the third number (c): ")
' Read the user's input and convert it to a double
Dim c As Double = Convert.ToDouble(Console.ReadLine())
' Calculate (a + b) * c
Dim result1 As Double = (a + b) * c
' Calculate a * c + b * c
Dim result2 As Double = a * c + b * c
' Display the results
Console.WriteLine("The result of (a + b) * c is: " & result1)
Console.WriteLine("The result of a * c + b * c is: " & result2)
End Sub
End Class