Assignment statements based on input value Write an if-else statement that assigns finalValue with userValue + 5 if userValue is greater than 100. Otherwise assign finalValue with userValue + 3. Function Save Reset MATLAB DocumentationOpens in new tab function finalValue = AssignValue(userValue) % Assign finalValue with userValue + 5 if userValue is greater than 100 % Otherwise, assign finalValue with userValue + 3 finalValue = 0; end 1 2 3 4 5 6 7 Code to call your function Reset AssignValue(200) 1 Run Function

Respuesta :

Explanation:

We have created a function named "Value" which takes one argument "userValue" as input from the user.

Then we used if else statement to check if the user has entered a value greater than 100 then add 5 to the userValue and assign it to finalValue.

Otherwise add 3 to the userValue and assign it to finalValue and display the result of finalValue.

Then we tested the function with Value(200) and Value(85) and it returned the correct output.

Matlab Code:

function finalValue=Value(userValue)

userValue=input("Please Enter a value: ");

if(userValue>100)

   finalValue=userValue+5;

else

   finalValue=userValue+3;

disp(finalValue)

end

Output:

Test 1:

Value()

Please Enter a value: 200

ans =    205

Test 2:

Value()

Please Enter a value: 85

ans =    88