Print the requested details of a right triangle to the screen.
Textbook: 2.4 - 2.5
Remember that a right trangle always has a 90° angle between its base and height. Assume here that base edge is horizontal, and that the 90° right angle is one of the two bottom angles of the triangle.
Write a program that starts with two sides of a right triangle--the base and the height. These two lengths should be stored as
Using these two sides, calculate the following details:
You may create additional variables as needed, however all output/results should change appropriately when only the initial value of base and height are changed.
You can use
Print out the length of each side and the result of each of the above calculations. Print one result per line. Be sure to label what each value is in your output. Thus, your output should be formatted something like this:
--Details of a right triangle-- Base: 3.0 Height: 4.0 Hypotenuse: 5.0 Perimeter: 12.0 Area: 6.0 Slope of hypotenuse: 1.3333333333333333
When you're done, change the values of your variables so that base = 7.5 and height = 18.
What to Submit
Grading [4 points]
|~ztomasze Index :
TA Details: ICS111:
|Last Edited: 08 Sep 2008|
©2008 by Z. Tomaszewski.