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

Write a MATLAB script that prompts the user for an integer between 10 and 100 by

ID: 2247742 • Letter: W

Question

Write a MATLAB script that prompts the user for an integer between 10 and 100 by displaying Enter an integer between 10 and 100: If the user enters a number (integer or not) outside this range, the following error will be displayed: Incorrect Entry. Number must be between 10 and 100. If the entry is within range but not an integer, it will display: Incorrect Entry. Number must be integer. In either of the above cases, the program will abort after the invalid entry. For a valid entry (for instance, 11) it will display the square of the number as follows: The square of your entry is 121

Explanation / Answer

x = input('Enter an integer between 10 and 100:')
% To check if input is integer or not.Integers give remainder 0
% when divided by 1
test = mod(x,1);
if(test != 0)
sprintf('Incorrect Entry. Number must be integer.')
else
if(x < 10 || x > 100)
sprintf('Incorrect Entry. Number must be between 10 and 100.')
else
sprintf('The square of your entry is %d',x*x)
end
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