Answer to Question #228750 in MatLAB for parth

Question #228750

Definition:

In this question we define code that reads in three positive numbers representing the lengths of the sides of a triangle and prints out a message saying “it’s equilateral” if all three sides are of equal length.


Testing:

On paper, or in a text file, write three new tests for the above program. As an example, two tests for this program might be.


inputs output
5 5 5  “it’s equilateral”
2 1 2  <no output>
1
Expert's answer
2021-08-23T12:20:57-0400


close all,
clear all,
clc,


sides = [
            5,5,5;
            2,1,2;
            3,2,1;
            3,4,5
        ];


for r=1:length(sides)
    a=sides(r,1); b=sides(r,2); c = sides(r,3);
    if (a==b && b==c && c==a)
        disp(['<',num2str(sides(r,:)),'> it’s equilateral']);
    else
        disp(['<',num2str(sides(r,:)),'> no output']);
    end
end


Matlab Output:

<5 5 5> it’s equilateral

<2 1 2> no output

<3 2 1> no output

<3 4 5> no output

>> 


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS