Question: Answer with MATLAB coding please step by step Write a script that keeps getting a number from the user. If that number is positive, print

Answer with MATLAB coding please step by step Write a script thatkeeps getting a number from the user. If that number is positive,print positive; negative, print negative. If it is zero, print zero andAnswer with MATLAB coding please step by step

Write a script that keeps getting a number from the user. If that number is positive, print positive; negative, print negative. If it is zero, print zero and then stop. Demonstrate with any sequence that mixes positives and negatives before giving it zero. . Step by Step Instructions: Start with the if statement. Get a number from the user and print out if it is positive. Check that it works by inputting a positive, then a negative, then a zero. It should only print something if the number is positive Now add the first elseif - in this case, check to see if the number is negative. o Check again with positive, zero, and negative - nothing should be printed for the zero Now add the final elseif. You could use else with no condition; not incorrect, just doesn't catch not a number (see below) OBTW NaN stands for not a number if you see this, you've gone and divided zero by zero or something like that. Now wrap the whole thing in a while loop. o What should the stopping criteria be? o There are two ways to do this: Either put an x = input() outside of the loop AND inside of the loop to set x OR take advantage of the fact that you know what you're check for and just set x to be any other number before the loop I prefer this because it's "safer" if you change the input statement . 1 Either put an x = input () outside of the loop AND inside of the loop to set x OR take advantage of the fact that you know what you're check for and just set x to be any other number before the loop I prefer this because it's safer if you change the input statement For grading purposes, declare a variable called flag and change the value of this variable depending on x o x is positive: flag = 1 o x is negative: flag = 2 O x is zero: flag = 3 o x is NaN: flag = 4 Self-check: Number, please: -1 -1.000000 is negative Number, please: 10.2 10.200000 is positive Number, please: 3.0 3.000000 is positive Number, please: -.00001 -0.000010 is negative Number, please: 0 x is zero 0.000000 If you want to be really, really correct: Number, please: 3 3.000000 is positive Number, please: -5 -5.000000 is negative Number, please: 2 2.000000 is positive Number, please: 1/0 Inf is positive Number, please: -1/0 -Inf is negative Number, please: 0/0 Neither negative or positive; must be not a number NaN Number, please: 0 Neither negative or positive; must be zero 0.000000

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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!