Question #268000

1) Write a procedure that will compute and return the average of three numbers. The procedure should have three parameters of type double representing the numbers to be averaged. (for example the average of x, y and z is given by (x+y+z)/3.0) 

2) what is the output of the following code? 

Private Sub btnBedrockClick(ByVal sender As System.Object, ByVal e As System.EventArgs)

   Dim strFullName As String = “Jonah Lomu”

   Dim strSecondName As String = “Va’inga Tuigamala”

   CountLength(strFullName, strSecondName)   lblEnd.Text = “My favorite was ” & strSecondName

End Sub

Private Sub CountLength(ByVal strFullName As String, ByRef strSecondName As String)

   lblFirst.Text = “The first name has ” & strFullName.Length & “ letters.”   lblSecond.Text = “The second name has ” & strSecondName.Length & “ letters.”

   strSecondName = “Joe Rokocoko”

End Sub

 


 

Expert's answer

Question 1

Imports System.IO


Module Module1
    Sub Main()
       


        Console.WriteLine("Average: " & computeAverage(5, 5, 8))




        Console.ReadLine()
    End Sub
    Function computeAverage(ByVal x As Double, ByVal y As Double, ByVal z As Double)
        Return (x + y + z) / 3.0
    End Function


End Module

Question 2

Answer:
The first name has 10 letters.
The second name has 17 letters.
My favorite was Joe Rokocoko
LATEST TUTORIALS
APPROVED BY CLIENTS