Question: SOS please help with this coding problem using matlab (a) Write a function called sumHundred that takes an integer as the input. The function should

SOS please help with this coding problem using matlab

(a) Write a function called sumHundred that takes an integer as the input. The function should determine whether the input is an integer between 1 and 100. If not, the function should display an appropriate error message. Turn in a printout of the function file.

(b) Test the function from the command prompt using (i) a number between 1 and 100, and (ii) a number greater than hundred. Turn in a printout of the command

prompt output for both cases.

(c) You will now modify your function sumHundred. Add some logic to it using for or while loops, such that the function evaluates the sum of all integers from 1 to

the input number. For instance, if the input number is 79, it should evaluate the sum of the first 79 integers. Do not use any built-in MATLAB functions. Turn in a

printout of the modified function file. Run two test cases from the command prompt and turn in a printout of the results along with the M-file.

(d) Save your sumHundred function as sumEvenHundred. Add another logic code to the original function, such that now it evaluates the sum of all even integers

from 1 to the input number. For instance, if the input number is 51, it should evaluate the sum of the even integers between 1 and 51. Turn in a printout of the function file and run it for two test cases from the command prompt.

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!