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.
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.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 1 images
Knowledge Booster
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.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education