Ask Question
27 June, 08:27

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. dat123 44.205 44.287Here might be examples of executing the script:>> parttolEnter the part weight: 44.33The part 123 is not in range>> parttolEnter the part weight: 44.25The part 123 is within range

+4
Answers (1)
  1. 27 June, 10:39
    0
    First, create the parttolerance. dat file with the line in the question. This can easily be done by using the echo command from the command line:

    echo 123 44.205 44.287 >> parttolerance. dat

    Then write a simple script file that prompts the user for the weight and then compares that input to the values within the file created above. If the value of the weight is within the range, then print the value is within range. Otherwise print it is not within range.

    Explanation:

    / / create the parttolerance. dat file

    echo 123 44.205 44.287 >> parttolerance. dat

    Shell script

    #!/bin/bash echo

    "Enter the part weight: "

    read input_weight

    IFS=' ' while IFS=' '

    read - r col1 col2 col3 do

    part_number="$col1"

    file_weight_lower="$col2"

    file_weight_upper="$col3"

    done
    if (($ (bc << = $file_weight_lower && $input_weight 0)); then

    echo "The part $part_number is within range"

    else

    echo "The part $part_number is not in range"

    fi

    run script:

    ./parttol. sh
Know the Answer?
Not Sure About the Answer?
Find an answer to your 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 ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers