Question: This uses MATLAB code 2. (20 pts) Write a program that will collect one positive integer from the user. Validation is required. Specifications: 2) The
2. (20 pts) Write a program that will collect one positive integer from the user. Validation is required. Specifications: 2) The program will check if the user enters nothing, or non-numeric value, or not a positive integer. It will keep prompting until the user enters a positive integer. 3) Design your own prompt and feedback. This strategy should become one of the requirements for your final project, in order to make the collection of input robust. Functions you may need: isempty),isnan (),length), str2double (), str2num (). 3. (40 pts) Write a program that will collect numbers from the user until the user enters a non- numeric value. It then returns the sum and the average of all numbers. Example run: Enter a number: 2.5 Enter a number: 2 Enter a number: 59 Enter a number: 2 Enter a number: 9 Enter a number: 1.1 Enter a number:9 The sum of the 6 numbers entered is 75.6. The average is 12.6 2. (20 pts) Write a program that will collect one positive integer from the user. Validation is required. Specifications: 2) The program will check if the user enters nothing, or non-numeric value, or not a positive integer. It will keep prompting until the user enters a positive integer. 3) Design your own prompt and feedback. This strategy should become one of the requirements for your final project, in order to make the collection of input robust. Functions you may need: isempty),isnan (),length), str2double (), str2num (). 3. (40 pts) Write a program that will collect numbers from the user until the user enters a non- numeric value. It then returns the sum and the average of all numbers. Example run: Enter a number: 2.5 Enter a number: 2 Enter a number: 59 Enter a number: 2 Enter a number: 9 Enter a number: 1.1 Enter a number:9 The sum of the 6 numbers entered is 75.6. The average is 12.6
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
