Write a complete Matlab script that ask the user to enter a

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.

Solution

% 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
%}

 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 f

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site