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

1. Write a MATLAB function, named calc that will ask the user to enter the lengt

ID: 3906370 • Letter: 1

Question

1. Write a MATLAB function, named calc that will ask the user to enter the lengths of the two legs of a right triangle, calculates the area and perimeter of the triangle. The function will accept no parameters, but it would return two values, i.e. area and perimeter. Area and perimeter will be display by a calling script/function to calc. Test your program with the following data: Legs: 10.25, 4.385

Create a program that prompts the user to enter a scalar value for the outside air temperature. If the temperature is equal to or above 80°F, send a message to the command window telling the user to wear shorts. If the temperature is between 60°F and 80°F, send a message to the command window telling the user that it is a beautiful day. If the temperature is equal to or below 60°F, send a message to the command window telling the user to wear a jacket or coat.

Explanation / Answer

***** Calculates the area and perimeter of the triangle *****

[v_ar,v_pr] = calc()

fprintf(' Area = %d ', v_ar);

fprintf(' Perimeter = %d ', v_pr);

function [ar,pr] = calc()

    disp 'Enter two legs of right triangle ';

    a=input('a =');

    b=input('b =');

    ar = a*b/2;

    cl=sqrt((a^2)+(b^2));

    pr=a+b+cl;

end;

***** Temperature *****

temp=input('Enter air temperature >');

if temp >= 80

    printf('Wear Shorts');

elseif temp > 60

    printf('It is a beautiful day');

else

    printf('Wear jacket or coat');

end

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