A data file \"parttolerance.dat\" stores on one line, a part number, and the min
ID: 3827132 • Letter: A
Question
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 rangeExplanation / Answer
%type parttolerance.dat
%123 44.205 44.287
fileID=fopen("parttolerance.dat","r")
A = fscanf(fileID,'%f')
t=input("Enter the part weight")
if t>A(2) && t<A(3)
fprintf("The part %d is within range",A(1))
else
fprintf("The part %d is not in range",A(1))
end
%OUTPUT :
Enter the part weight44.33
The part 123 is not in range