Hypotenuse Calculations) Define a method hypotenuse that calculates the hypotenuse of a right triangle when the lengths of the other two sides are given. The method should take two arguments of type double and return the hypotenuse as a double. Incorporate this method into an application that reads values for sidel and side 2 and performs the calculation with the hypotenuse method. Use Math methods pow and sqrt to determine the length of the hypotenuse for each of the triangles in Fig. $6.15 .[$ Note: Class Math also provides method hypot to perform this calculation.]
Imports System.IO
Module Module1
Sub Main()
Console.Write("Enter side 1: ")
Dim side1 As Double = Double.Parse(Console.ReadLine())
Console.Write("Enter side 2: ")
Dim side2 As Double = Double.Parse(Console.ReadLine())
Console.WriteLine("Hypotenuse: {0}", calculatesHypotenuse(side1, side2))
Console.ReadLine()
End Sub
Function calculatesHypotenuse(ByVal side1 As Double, ByVal side2 As Double)
Return Math.Sqrt(Math.Pow(side1, 2) + Math.Pow(side2, 2))
End Function
End Module
Comments
Leave a comment