Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using MATLAB , Write a function posnum that prompts the user to enter a positive number and loops to error-check. It returns the square root

Using MATLAB,

Write a function posnum that prompts the user to enter a positive number and loops to error-check. It returns the square root of the positive number entered by the user. It calls a subfunction in the loop to print an error message. The subfunction has a persistent variable to count the number of times an error has occurred. Here is an example of calling the function:

>> squarerootvalue = posnum

Enter a positive number: -5

Error #1: Follow instructions!

Does -5.00 look like a positive number to you?

Enter a positive number: -33

Error #2: Follow instructions!

Does -33.00 look like a positive number to you?

Enter a positive number: 4

squarerootvalue = 2

Step by Step Solution

3.28 Rating (145 Votes )

There are 3 Steps involved in it

Step: 1

function to find the squaroot of a number function squarootvalue posnum n inputEnte... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Java Programming, Comprehensive Version

Authors: Y. Daniel Liang

10th Edition

133761312, 978-0133761313

More Books

Students also viewed these Accounting questions