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

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 range

Explanation / 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

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