This question tests your ability to use if, for and while constructs. Submit a MATLAB script that does each of the following. a. Ask the user to input a number and display the following information about the number. Note that more than one message may be displayed. i. The entry is not a number. The isnumeric() function should be used for this. The code should do nothing else in this case. ii. iii. A message that states whether the number is zero, positive or negative. A message that states whether the number is an integer or not. The rem() or floor() functions may be used for this purpose. iv. A message that states whether or not the number is less than or equal to 5 and greater than or equal to -2. C. b. Ask the user to input a number. Calculate the product of the numbers from the entered number to twice its value in steps of 0.5. For example, if the entered number was 1.2 the answer would be 1.2*1.7*2.2. Adding 0.5 to 2.2 gives a number bigger than 2*1.2 You should use a for loop to answer this question and you need not perform error checking on the input. My example may indicate a while loop would be a better choice but it is not too difficult to create a for line. Create a random integer between 1 and 6 inclusive. This can be done using the line: X = randi(6); Use a while loop to count how many attempts the person running the code needs to guess the number. At the end of the code display the random number and the number of attempts using the fprintf() function.

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter5: Looping
Section: Chapter Questions
Problem 3GZ
icon
Related questions
Question
3. This question tests your ability to use if, for and while constructs. Submit a MATLAB script that
does each of the following.
a. Ask the user to input a number and display the following information about the
number. Note that more than one message may be displayed.
i. The entry is not a number. The isnumeric() function should be used for this.
The code should do nothing else in this case.
ii.
iii.
C.
A message that states whether the number is zero, positive or negative.
A message that states whether the number is an integer or not. The rem() or
floor() functions may be used for this purpose.
iv. A message that states whether or not the number is less than or equal to 5
and greater than or equal to -2.
b. Ask the user to input a number. Calculate the product of the numbers from the
entered number to twice its value in steps of 0.5. For example, if the entered number
was 1.2 the answer would be 1.2*1.7*2.2. Adding 0.5 to 2.2 gives a number bigger
than 2*1.2 You should use a for loop to answer this question and you need not
perform error checking on the input. My example may indicate a while loop would be
a better choice but it is not too difficult to create a for line.
Create a random integer between 1 and 6 inclusive. This can be done using the line:
X = randi(6);
Use a while loop to count how many attempts the person running the code needs to
guess the number. At the end of the code display the random number and the number
of attempts using the fprintf() function.
Transcribed Image Text:3. This question tests your ability to use if, for and while constructs. Submit a MATLAB script that does each of the following. a. Ask the user to input a number and display the following information about the number. Note that more than one message may be displayed. i. The entry is not a number. The isnumeric() function should be used for this. The code should do nothing else in this case. ii. iii. C. A message that states whether the number is zero, positive or negative. A message that states whether the number is an integer or not. The rem() or floor() functions may be used for this purpose. iv. A message that states whether or not the number is less than or equal to 5 and greater than or equal to -2. b. Ask the user to input a number. Calculate the product of the numbers from the entered number to twice its value in steps of 0.5. For example, if the entered number was 1.2 the answer would be 1.2*1.7*2.2. Adding 0.5 to 2.2 gives a number bigger than 2*1.2 You should use a for loop to answer this question and you need not perform error checking on the input. My example may indicate a while loop would be a better choice but it is not too difficult to create a for line. Create a random integer between 1 and 6 inclusive. This can be done using the line: X = randi(6); Use a while loop to count how many attempts the person running the code needs to guess the number. At the end of the code display the random number and the number of attempts using the fprintf() function.
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Events
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning