Question: 1) Write a script that tests whether the user can follow instructions. It prompts the user to enter an x. If the user enters anything

1) Write a script that tests whether the user can follow instructions. It prompts the user to enter an x. If the user enters anything other than an x, it prints an error message otherwise, the script does nothing. Do this using the error function. (DONT USE 'fprintf' and USE THE ERROR FUNCTION)

3) The Pythagorean theorem states that for a right triangle, the relationship between the length of the hypotenuse c and the lengths of the other sides a and b is given by:

c2 = a2 + b2

Write a script that will prompt the user for the lengths a and c, call a function findb to calculate and return the length of b, and print the result. Note that any values of a or c that are less than or equal to zero would not make sense, so the script should print an error message if the user enters any invalid value. Here is the function findb:

findb.m

function b = findb(a,c)

% Calculates b from a and c

b = sqrt(c^2 - a^2);

end

4) Write a function that will receive one number as an input argument. It will present the user with a choice of using ceil, round, or sign. Do this as integers, e.g., 1 for ceil, 2 for round, and 3 for sign. Using a switch statement, the function will then calculate and return the requested function (e.g., if round is chosen, the function will return the rounded value of the input argument).

5) Modify the function in Question 4 to use a nested if-else statement instead.

8).Write a script that will

Prompt the user for an angle in degrees

calculate the angle in radians . (Note: p radians = 180)

Print the result

Note: When I write the script and use 'function' there is going to be an error saying that "function definitions are not permitted in this context."

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

It seems like there are several questions but some numbering might be missing or incorrect since th... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!