Develop an algorithm that would compute the area of a triang

Develop an algorithm that would compute the area of a triangle given the lengths of its three sides. The algorithm should prompt the user to enter the length values one by one, make sure that the triangle inequality is not violated, and apply Heron \'s formula. (Look up the definitions of the triangle inequality and Heron\'s formula. Include them in your algorithm description!) If the user input does not correspond to a valid triangle, then an error message should be displayed. Otherwise, the algorithm should output the area value. Document your algorithm in Microsoft Word using pseudocode.

Solution

BEGIN

/Declare three variables for three sides of triangle, perimeter/2 and area

Declare real s1

Declare real s2

Declare real s3

Declare real s

Declare real area

//get the sides of triangle from user

Display \"Enter side1 of triangle\"

Input s1

Display \"Enter side2 of triangle\"

Input s2

Display \"Enter side3 of triangle\"

Input s3

if((s1+s2) >s3 && (s2+s3)>s1 && (s1+s3)>s2)

Display \" Triangle inequality is not violated\"

s = (s1+s2+s3)/2

area = sqrt(s*(s-s1)*(s-s2)*(s-s3))

Display \"Area of Triangle = \"area

END

 Develop an algorithm that would compute the area of a triangle given the lengths of its three sides. The algorithm should prompt the user to enter the length v

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site