Back to DFS's Workshop Page
Back to Agenda Page
Write a set of scripts to be used through a web browser to calculate the length of the hypotenuse of a right triangle given the lengths of the other two sides. When reporting the results, provide a PNG to illustrate the result. To see how this could work, view this possible solution.
This proposed solution consists of four steps. You will be asked to create a total of five scripts, two of which will not be used in the final solution. They are used solely to make development easier.
For this problem, you are to cannibalize any available code and write five scripts which will do the following.
This is a preliminary test script to make sure that the mathematics and overall algorithm are correct. Running it from the Command Line eliminates any additional problems which might arise due to the use of forms and the passing of values from one script to another.
Create hypotenuse.html as the frontend for interacting with the user.
Create hypotenuse.php to process the user's input and report the results. At this time, you will not be attempting to produce the graphical representation of the triangle.
echo "<p><img src=whatever.png "; echo "alt=\"This is the triangle\" border=4></p>\n";
Create hypotpiccall.php to test the PHP script which creates the picture. The following would be sufficient.
<?php echo "<p><img src=drawtriangle.php?a=3&b=4&c=5 "; echo "alt=\"This is the triangle\" border=4></p> ?>
Create drawtriangle.php to draw a picture of the triangle. Check out the Image Functions page.
Header("Content-type: image/png");
To see how this could work, view this possible solution.