Q:

A data file “parttolerance.dat” stores, on one line, a part number, and the minimum and maximum values for the valid range that the part could weigh

0

 A data file “parttolerance.dat” stores, on one line, a part number, 

and the minimum and maximum values for the valid range that the 

part could weigh. Write a script parttol that will read these values from

the file, prompt the user for a weight, and print whether or not that 

weight is within range.

For example, IF the file stores the following:

>> type parttolerance.dat

123 44.205 44.287

Here might be examples of executing the script:

>> parttol

Enter the part weight: 44.33

The part 123 is not in range

>> parttol

Enter the part weight: 44.25

The part 123 is within range

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

parttol.m

load parttolerance.dat

partno = parttolerance(1);

minwt = parttolerance(2);

maxwt = parttolerance(3);

partwt = input('Enter the part weight: ');

if partwt > minwt && partwt < maxwt

 fprintf('The part %d is within range\n',partno)

else

 fprintf('The part %d is not in range\n',partno)

end

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now