A data file \"parttolerance.dat\" stores on one line, a part number, and the min
ID: 3826571 • 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
Use strict;
Use warnings;
Open(FH,">parttolerance.dat")||die("can not open this file");
@arr=<FH>
Close FH
@values=Split(" ",$arr[0]);
Print("Enter a value");
$line=<stdin>;
Chomp($line);
If($line>=$arr[1]||$line<$arr[2])
{
Print("The $value[0] is with in the range");
}
Else
Print("The $value[0] is not with in the range");