Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
Solved

Answer not doubling for correct response

Posted on 2009-02-21
Medium Priority
175 Views
Within my formula code, I cannot get my response to properly display the output of the Pythagorean theorem formula: a2 + b2 = c2. How do I properly code to get correct response?
``````Private Sub btnConvert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConvert.Click

If Theorem.Checked Then
'hypothenuse
txtOutput.Text = Math.Pow(NUDradius.Value, 2) + Math.Pow(NUDheight.Value, 2)
ElseIf Cylinder.Checked Then
'cylinder volume
txtOutput.Text = Math.Pow(NUDradius.Value, 2) * NUDheight.Value * Math.PI
End If
End Sub
``````
0
Question by:probeg

LVL 39

Accepted Solution

abel earned 2000 total points
ID: 23701057
What do you mean with incorrect? The result of your formula is the quadrature of the hypotenuse, which, to show up as the length of the hypotenuse, first has to be square rooted:

Btw: I don't know what NUDradius is, but it sounds like something of the radius of a circle, are you sure that's the value you need? Shouldn't it be something like height / width of the rectangle/triangle?
0

LVL 9

Expert Comment

ID: 23701063
If you are trying to obtain the value of c then you need to use the following:

``````txtOutput.Text = Math.Sqrt(Math.Pow(NUDradius.Value, 2) + Math.Pow(NUDheight.Value, 2))
``````
0

Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
When you discover the power of the R programming language, you are going to wonder how you ever lived without it! Learn why the language merits a place in your programming arsenal.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Progress
Suggested Courses
Course of the Month10 days, 22 hours left to enroll