Exercise
Equivalent operations
Objetive
Write a Visual Basic (VB.Net) program to ask the user for three numbers (a, b, c) and display the result of (a+b)·c and the result of a·c + b·c.
Code
' 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