Hello everyone I am still working on this. I have a few questions. I am starting to understand a little more. The only question I dont understand is this...
From the main procedure call a function procedure which calculates and returns a value for the “hypotenuse” equal to the square root of (x squared + y squared). You will have to pass the values of x and y to this function procedur开发者_JS百科e. The procedure should calculate and return a double type value. The value that is returned by this function procedure should be equal to the square root of (x squared + y squared). Also from the main procedure call a sub procedure to display the values of x, y, and the hypotenuse.
This just through me off. here is what i have so far.Now would i declare this in the x or should I have x and y together?
Option Strict On
Option Explicit On
Module Module1
Sub Main()
Dim x As Double = width()
Dim y As Double = height(x)
Console.Read()
End Sub
Private Function width() As Double
Dim x As Double
x = Convert.ToDouble(Console.ReadLine())
Return x
End Function
Private Function height(ByVal x As Double) As Double
Dim y As Double
y = Convert.ToDouble(Console.ReadLine())
Return y
End Function
Private Sub hypotenuse(ByVal x As Double, ByVal y As Double)
y = Math.Sqrt(x squared + y squared)
Console.WriteLine(x & " X = " & y & " Y")
End Sub
End Module
You already have the width and height. Now you need to calculate the hypotenuse - you already have the formula, you just need to translate that into code (as this is homework, I'm not going to give it :-) ). Store the result in another Double.
Then call a procedure (that you still need to create) where you pass the three values and print them (Console.Write / Console.WriteLine).
(x squared + y squared)
only makes sense in the problem statement and is not legal vb code. You will need to convert this to a working expression.
I also don't like how you do y = the hipotenuse
. Create a new variable instead of clobbering your inputs. (since you also want to use x and y latter as shown by the Console.Writeline
)
精彩评论