Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Build a function that is going to robustly (repeatedly) confirm that the user en

ID: 3545215 • Letter: B

Question

Build a function that is going to robustly (repeatedly) confirm that the user entered a valid number for a dimension. This function should have two function inputs, the first a numeric value, the second a string stating what the value represents. This function should have 1 function output a valid number. This function should employ a loop that will tell the user he/she entered an invalid number for that dimension and ask the user to re-enter the value for that dimension if he/she entered a number <= 0. This function should not use and selection control structure.


calculating the volume of object of different shapes using a switch so that it calls the function to confirm the user's input is greater than 0 before calculating the volume. The script file should use an input statement before the function is called to store the initial value for the dimension.


For example supposed the user chose cube as the shape. The script file should use an input function to enter the size of the edge of the cube. Then the function to confirm should be called in a similar manner to (you do NOT have to call your function checkdim)

edge = checkdim(edge, 'side of cube'.)

In the function when the user's input was not greater than zero a message similar to
The side of the cube cannot be less than or equal to 0!

and the user should be asked to be prompted to input another value that is valid similar to

Enter a value that is greater than 0.

Explanation / Answer

function .. ( save function in a file named edgedim.m ( its important))

function [ n ]= edgedim (edge)

if edge>0

fprintf('edge is valid');

n=1;

else

fprintf('edge is invalid');

n=0;

end


script file ( save it at same location as (input_foo))


clc;

clear all;

close all;




edge= input('dimension:');

type=input('what it represents:','s');


na=edgedim(edge);


while na==0

edge= input('dimension:');

type=input('what it represents:','s');

na=edgedim(edge);

end


.. please rate me best answer and increase points if possible


Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote