Write a program that will accept three input data width leng

Write a program that will accept three input data (width, length, height) for a part, and reject the part if it falls outside the following tolerances: width = (5.200, 5.210) length = (4.600, 4.700) height = (4.400, 4.550) Try it out with the following part inspection data (width, length, height) for six parts: (5.300, 4.605, 4.500), (5.203, 4.605, 4.505), (5.208, 4.685, 4.505), (5.300, 4.605, 4.520), (5.201, 4.607, 4.440), (5.208, 4.617, 4.430)

(Matlab program)

Solution


inp1 = input(\'Enter the width:\',\'s\');
w = str2double(inp1);

inp2 = input(\'Enter the length:\',\'s\');
l = str2double(inp2);

inp3 = input(\'Enter the height:\',\'s\');
h = str2double(inp3);

if ( ( w < 5.200 || w > 5.210 ) || ( l < 4.600 || l > 4.700 ) || ( h < 4.400 || h > 4.550) )
disp(\'Part is rejected\');
else
disp(\'Part is accepted\');
end

%-----------------------------------Output------------------------------------------

>> test3
Enter the width:5.3
Enter the length:4.605
Enter the height:4.5
Part is rejected
>> test3
Enter the width:5.203
Enter the length:4.605
Enter the height:4.505
Part is accepted
>> test3
Enter the width:5.208
Enter the length:4.685
Enter the height:4.505
Part is accepted
>> test3
Enter the width:5.3
Enter the length:4.605
Enter the height:4.520
Part is rejected
>> test3
Enter the width:5.201
Enter the length:4.607
Enter the height:4.440
Part is accepted
>> test3
Enter the width:5.208
Enter the length:4.617
Enter the height:4.43
Part is accepted
>>

Write a program that will accept three input data (width, length, height) for a part, and reject the part if it falls outside the following tolerances: width =

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site