Ask Question
18 September, 05:32

Test inputs write a function called checkinputs which checks if three inputs parameters are the correct data types. the first, second, and third input variables must be a string, numeric, and logical data type, respectively. the output of checkinputs should be a logical row array, errorcode, with 4 values.

+1
Answers (1)
  1. 18 September, 05:42
    0
    Here you go,

    Program:

    function errorCode = CheckInputs (name, gpa, enrollStatus)

    %Create a errorCode as a 1x4 logical array

    errorCode=[true true true false];

    %Check number input arguments taken by the function

    %If the number of arguments are less than 3, assign the

    %4th array element in errorCode to true

    if nargin<3

    errorCode (4) = true;

    errorCode (3) = false;

    errorCode (2) = false;

    errorCode (1) = false;

    %Otherwise (if there are three parameters),

    else

    %Check whether the first parameter is a string are not

    %and set the first array element with true, if the

    %first argument is string

    if ischar (name)

    errorCode (1) = ~ (ischar (name));

    end

    %Check whether the second parameter is a numeric value are not

    %and set the second array element with true, if the

    %second argument is a numeric value

    if isnumeric (gpa)

    errorCode (2) = ~ (isnumeric (gpa));

    end

    %Check whether the third parameter is a logical value are not

    %and set the third array element with true, if the

    %third argument is a logical value false

    if islogical (enrollStatus)

    errorCode (3) = ~ (islogical (enrollStatus));

    end

    end

    end
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Test inputs write a function called checkinputs which checks if three inputs parameters are the correct data types. the first, second, and ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers