Average Learn programming Visual Basic (VB.net)

Lesson:

First contact with Visual Basic (VB.net)


Exercise:

Average 11


Objetive:

Write a Visual Basic (VB.net) program to calculate and display the average of four numbers entered by the user.


Code:

Imports System
Public Class exercise9
    Public Shared Sub Main()
        Dim num1, num2, num3, num4 As Integer
        Console.Write("Enter the First number: ")
        num1 = Convert.ToInt32(Console.ReadLine())
        Console.Write("Enter the Second number: ")
        num2 = Convert.ToInt32(Console.ReadLine())
        Console.Write("Enter the third number: ")
        num3 = Convert.ToInt32(Console.ReadLine())
        Console.Write("Enter the four number: ")
        num4 = Convert.ToInt32(Console.ReadLine())
        Dim result As Integer = (num1 + num2 + num3 + num4) / 4
        Console.WriteLine("the average of {0} , {1} , {2} , {3} is: {4} ", num1, num2, num3, num4, result)
    End Sub
End Class