Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Suppose you know the lengths and the angle between two adjacent sides of a trian

ID: 3039273 • Letter: S

Question

Suppose you know the lengths and the angle between two adjacent sides of a triangle, as shown in the drawing below. You can find the area of the triangle using the following relationship: tAREA = 1/2 * a * b * sin(x) Open the script editor by using the drop down menu, Applications and select Scinotes. Write a script file to compute the area of the triangle using the equation tAREA = 1/2 * a * b * sin(x) and save it in an .sce file called TriangleArea. The values a, b and x should be loaded using the input command. Remember trig functions in SCILAB expect the angles to be in units of radians. Use the printf command to display the input variables, their value and units and display the output variable, tAREA giving its value and units. Use the following values to test your results: a = 5 ft, b = 6 ft, and x = 23 degree. a = 12 ft, b = 2 ft, and x = 78 degree. Run your script file, and test your results. What would happen if you used an angle greater than 180 degree? When you tried it, does it make sense? Is there a way to adjust your script with this in mind?

Explanation / Answer

Here I am giving script file in python language, you can adjust it any language according to your preference.

a = input("Enter the length of side1")

b = input("Enter the length of side2")

x = input("Enter the angle between sides")

tAREA = 0

tAREA = (1/2)*a*b*math.sin(x)

print tAREA+"deg"

Now, If Someone has used angle above 180 deg. then it would show negative area that is not possible.

So, we can implement it by using conditionals. Let see again --------

a = input("Enter the length of side1")

b = input("Enter the length of side2")

x = input("Enter the angle in degree between sides")

tAREA = 0

if x > 180:

tAREA = {- (1/2)*a*b*math.sin(x)}

else:

tAREA = (1/2)*a*b*math.sin(x)

print tAREA

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote