Exercise
Use of {0} and comments
Objetive
Write a Visual Basic (VB.Net) program to ask the user for three numbers and display their multiplication. The first line must be a comment with your name and surname. It MUST look as follows:
// Your Name and Surname
Enter the first number to multiply:
12
Enter the second number to multiply:
23
Enter the third number to multiply:
2
Code
' Import the System namespace to use Console class
Imports System
Public Class Program
' Main subroutine, entry point of the program
Public Shared Sub Main()
' Prompt the user to enter the first number
Console.Write("Enter the first number to multiply: ")
Dim number1 As Integer = Convert.ToInt32(Console.ReadLine())
' Prompt the user to enter the second number
Console.Write("Enter the second number to multiply: ")
Dim number2 As Integer = Convert.ToInt32(Console.ReadLine())
' Prompt the user to enter the third number
Console.Write("Enter the third number to multiply: ")
Dim number3 As Integer = Convert.ToInt32(Console.ReadLine())
' Calculate the result of the multiplication
Dim result As Integer = number1 * number2 * number3
' Display the result using string formatting with {0}
Console.WriteLine("The result of multiplying {0}, {1}, and {2} is: {3}", number1, number2, number3, result)
End Sub
End Class