This is a quick example of how to implement a basic math formula within your program.
The example project only contains one form, with three fields and a button:
All three fields need to be populated with values, which is checked for in the code. Also, this example will only let you enter numeric values in the fields, in order to prevent errors which would be generated by entering other (or invalid) characters.
Given the length of all three sides of a triangle, along with the use of Herons formula, the program will calculate the total area of the triangle.
Just a little something to get some folks started in the right direction on their homework assignments. 😉
Webmaster Note
This article has been updated to reflect the correct outcome. The previous version of the article made use of an incomplete process to find the area of a triangle, and skipped the use of Herons formula.
Herons formula states:
AREA = sqrt(s(s-a)(s-b)(s-c))
Where:
s = SemiPerimeter of the triangle, and a, b, and c are the lengths of the individual sides.
Thanks to an angry math nerd in middle America, who has a penchant for irate rants, for pointing out the mistake. The code has been updated, and the author responsible for the error has been beaten to within an inch of his life.
To the angry old man, I hope this sates your quest for accuracy. Now that the author and myself have fixed the error, you have all the time in the world to fix dotnetplayground. That is, unless you are dedicating your life to harassing random websites.
Attachments
File | Uploaded | Size |
---|---|---|
389-20190416-150447-TriangleArea.zip | 4/16/2019 3:04:47 PM | 1932 |