Question

Your math professor asked you to determine whether triangles are equilateral, isosceles, or scalene triangles. You...

Your math professor asked you to determine whether triangles are equilateral, isosceles, or scalene triangles. You need to write a MATLAB program that accepts the side lengths for sides A, B, and C of a triangle and compares the side lengths in order to determine if the triangle is equilateral, isosceles, or scalene. Each triangle will only be classified as a single type based on the definitions below:

1. An equilateral triangle is a triangle in which all three sides are equal

2. An isosceles triangle is a triangle that has two sides of equal length.

3. A scalene triangle is a triangle that has three unequal sides

For example, if a triangle has three sides of equal length, the code will only classify that triangle as equilateral, rather than both equilateral and isosceles.

1) Write a MATLAB script file that:

a. Takes numeric input from a user of the side lengths for sides A, B, and C of a triangle, where each side length is in centimeters. You may assume the user will enter valid values for the side lengths.

b. Uses a conditional structure to compare the lengths of the triangles, and output whether it is an equilateral, isosceles or scalene triangle.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

a=input('Enter A:')
b=input('Enter B:')
c=input('Enter C:')
if(a==b && b==c)
   disp('Equilateral triangle')
elseif((a==b) || (b==c) || (a==c))
   disp('Isosceles triangle')
else
   disp('Scalene triangle')
end

Add a comment
Know the answer?
Add Answer to:
Your math professor asked you to determine whether triangles are equilateral, isosceles, or scalene triangles. You...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 10. Write a Python program to check if a triangle is equilateral, isosceles or scalene. An...

    10. Write a Python program to check if a triangle is equilateral, isosceles or scalene. An equilateral triangle is a triangle in which all three sides are equal. A scalene triangle is a triangle that has three unequal sides An isosceles triangle is a triangle with (at least) two equal sides

  • ***IN PYTHON: Scalene triangle: All sides have different lengths Isosceles triangle: Two sides have the same...

    ***IN PYTHON: Scalene triangle: All sides have different lengths Isosceles triangle: Two sides have the same length Equilateral triangle: All sides are equal Write a program to ask for the length of 3 sides a, b and c. Ask for three sides at a time Determine the type of triangle given three sides Handle all kinds of errors - 1. not integers, int() conversion fails 2. not enough args, 3. too many arguments HINT: use the len() function to check...

  • Welcome to the Triangles program Enter length 1: 3 Enter length 2: 5 Enter length 3:...

    Welcome to the Triangles program Enter length 1: 3 Enter length 2: 5 Enter length 3: 5 Enter the base: 5 Enter the height: 8 --------------------- The triangle is Isosceles since it has two equal length sides. Isosceles triangle also has two equal angles The area is: 20 The permimeter is: 13 Continue? (y/n): y Enter length 1: 10 Enter length 2: 10 Enter length 3: 10 Enter the base: 10 Enter the height: 7 --------------------- The triangle is Equilateral...

  • PLEASE READ AND CODE IN BASIC C++ CODE. ALSO, PLEASE CODE USING THIS DO WHILE LOOP...

    PLEASE READ AND CODE IN BASIC C++ CODE. ALSO, PLEASE CODE USING THIS DO WHILE LOOP AND FORMAT: #include <iostream> using namespace std; int main() { //variables here    do { // program here             }while (true);    } Objectives To learn to code, compile and run a program containing SELECTION structures Assignment Write an interactive C++.program to have a user input the length of three sides of a triangle. Allow the user to enter the sides...

  • help im alittle lost my teacher posted all this its suppose to be in C++ language....

    help im alittle lost my teacher posted all this its suppose to be in C++ language. can yoh leave comments ans type the code thank you Write a C++ program that accepts the lengths of three sides (a,b,c) of a triangle as input from the user Validate the user input, so that sides a, b, c can only be POSITIVE. The program output should indicate whether or not the triangle is an Equilateral Triangle, a Right Triangle, Isosceles which is...

  • This question is from the textbook "Python for ArcGIS" by Laura Tateosian: Write a script "triangles.py"...

    This question is from the textbook "Python for ArcGIS" by Laura Tateosian: Write a script "triangles.py" that takes three arguments, the lengths of three sides of a triangle. Then define the following three functions: 1. perimeter takes three side lengths as arguments and returns the perimeter length. 2. triangleType takes three side lengths as arguments, determines if it is an equilateral triangle, an isosceles triangle, or neither. The result is returned. 3. area takes three side lengths as arguments and...

  • It is required to read three real numbers that represent the sides of a possible triangle. For th...

    It is required to read three real numbers that represent the sides of a possible triangle. For the sides to form a triangle, the sum of each pair of sides must be greater than the third side. This has to be fulfilled for each pair of sides. The program must determine the values ​​of the following alphanumeric variables (string type): tria: You will be assigned the value "triangle" if the three real numbers form a triangle or the value of...

  • //////// ONLY JAVA **** //////// ONLY JAVA **** 5. In a right triangle, the square of...

    //////// ONLY JAVA **** //////// ONLY JAVA **** 5. In a right triangle, the square of the length of one side is equal to the sum of the squares of the lengths of the other two sides. Write a program that prompts the user to enter the lengths of three sides of a triangle and then outputs a message indicating whether the triangle is a right triangle. (Have the user enter the lengths 3, 4, and 5).

  • In a right triangle, the square of the length of one side is equal to the...

    In a right triangle, the square of the length of one side is equal to the sum of the squares of the lengths of the other two sides. Write a program that prompts the user to enter the lengths of three sides of a triangle and then outputs a message indicating whether the triangle is a right triangle. If the triangle is a right triangle, output It is a right-angled triangle If the triangle is not a right triangle, output...

  • The "for more practice part" using matlab If the lengths of two sides of a triangle...

    The "for more practice part" using matlab If the lengths of two sides of a triangle and the angle between them are known, the length of the third side can be calculated. Given the lengths of two sides (b and c) of a triangle, and the angle between them alpha in degrees, the third side a is calculated as follows a^2 = b^2 + c^2 - 2b c cos(alpha) White a script thirdside that will prompt the user and read...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT