สถานะการส่งล่าสุด: -

If-else 2: triangle-identifier

If-else 2: triangle-identifier


Q2. Triangle-identifier

Task: make a program that identifies triangles type. give the user a choice to identify triangle by side or angle. Also, notify user if the given values are not triangle (c < a + b (c as a longest side) and sum of angles must be 180 degrees)

Classification of triangles
cite image: https://www.cuemath.com/geometry/types-of-triangle/

Example Output 1:

Welcome to Triangle Identifier! How do you want to identify your triangle (side/angle): side
Enter side a: 3
Enter side b: 3
Enter side c: 3
Your triangle is an Equilateral triangle!

Example Output 2:

Welcome to Triangle Identifier! How do you want to identify your triangle (side/angle): side
Enter side a: 4
Enter side b: 5.5
Enter side c: 6
Your triangle is a Scalene triangle!

Example Output 3:

Welcome to Triangle Identifier! How do you want to identify your triangle (side/angle): angle
Enter angle a: 60
Enter angle b: 60
Enter angle c: 60
Your triangle is an Acute triangle!

Example Output 4:

Welcome to Triangle Identifier! How do you want to identify your triangle (side/angle): angle
Enter angle a: 90
Enter angle b: 30
Enter angle c: 60
Your triangle is a Right triangle!

Example Output 5:

Welcome to Triangle Identifier! How do you want to identify your triangle (side/angle): BANANA
Invalid choice.

Example Output 6:

Welcome to Triangle Identifier! How do you want to identify your triangle (side/angle): side
Enter side a: 1
Enter side b: 1
Enter side c: 2500
This is not a triangle!

Example Output 7:

Welcome to Triangle Identifier! How do you want to identify your triangle (side/angle): angle
Enter angle a: 1
Enter angle b: 1
Enter angle c: 2500
This is not a triangle!