Criteria Evaluation Routine Specifications
A data extraction tool is being designed for a loan processing system. One of the key functionalities of the tool allows a user to define an extraction criteria based on any combination of fields, selected from a predefined list of fields. You need to write code that will evaluate the extraction criteria and determine if an account satisfies the criteria or not.
INPUTS and OUTPUTS
Input criteria file
Each row of the file will contain a unique criterion. The file will be 500 bytes long. The program will have to read each row of the file and evaluate the row in the data file and write the output (a true or a false) to the output file.
Data file
The file will contain a row for each field. The file is a 133 bytes FB file. The format of a row will be as follows:
<field name><space><value>
All the fields are numeric and have the following PIC clause PIC 9(04). The field names can vary in length.
Output file
The output file will contain a “TRUE†or a “FALSE†for each row of the input criteria file.
PROCESS
The tool will evaluate a data present in the data file against one or many criteria present in the criteria file. If the data present in the data file satisfies a criterion, then a row corresponding to the criterion is entered in the output file with a “TRUEâ€. If the data present in the file does not satisfies a criterion, then a row corresponding to the criterion is entered in the output file with a “FALSEâ€.
CRITERIA
Format
The following is the format of the criteria in the criteria file:
<field name><space><comparative operator><space><data value><space><Logical operator><space>
The data value will not have preceding zeroes. This structure repeats as much time as the 500 bytes of the criteria file would permit.
Comparative Operators
The following are the operators to compare a field to a given value:
· EQ - Equal
· NE - Not Equal
· GE - Greater than equal
· GT - Greater than
· LT - Less than
· GE - Greater than equal
· LE - Less than equal
This operator is 2 bytes long.
Logical Operators
The following are the operators that connect multiple comparisons and they appear in the order of precedence
· OR+ - An OR which has high precedence than an AND.
· AND - Typical AND
· OR - Typical OR
This operator is 3 bytes long.
An example
Consider the following data file content
ABC 0002
TYY 0003
OPP 0000
The following equation evaluates to a False.
ABC EQ 1 AND TYY LT 5 OR+ OPP LT 1
And the following equation evaluates to a True
ABC EQ 1 AND TYY LT 5 OR OPP LT 1
Please let me know about the logic of coding part...