Write a complete Matlab script that ask the user to enter a number larger than 1
ID: 3925206 • Letter: W
Question
Write a complete Matlab script that ask the user to enter a number larger than 100. You should use a loop at this point in the program to make sure that user followed your instructions; if the user messed up, your loop should again prompt the user to enter a number larger than 100. Once you are certain the provided number is bigger than 100, print out the square root of the number and end the program. Write a complete Matlab script that ask the user to enter a number larger than 100. You should use a loop at this point in the program to make sure that user followed your instructions; if the user messed up, your loop should again prompt the user to enter a number larger than 100. Once you are certain the provided number is bigger than 100, print out the square root of the number and end the program.Explanation / Answer
% matlab code to determine square root of number larger than 100
while true
number = input("Enter number larger than 100: ");
if number <= 100
disp("Invalid Input ");
else
break;
end
end
fprintf("Square root of %f is %0.3f ",number, sqrt(number));
%{
output:
Enter number larger than 100: 25
Invalid Input
Enter number larger than 100: 101
Square root of 101.000000 is 10.050
%}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.