22 Program using Procedure to take 3 subject marks and find average in VB.NET.

Code:

Module Module1

    Public Class Student
        Public s1, s2, s3 As Integer
        Public avg, sum As Double

        Sub accept()

            Console.WriteLine(" Enter marks of 3 subject: ")
            s1 = Console.ReadLine()
            s2 = Console.ReadLine()
            s3 = Console.ReadLine()

            sum = s1 + s2 + s3

            avg = sum / 3.0

        End Sub

        Sub display()
            Console.WriteLine("Average: " & avg)
        End Sub


    End Class

    Sub Main()
        Dim s As New Student
        s.accept()
        s.display()

        Console.ReadKey()
    End Sub

End Module




Output:  


Previous
Next Post »