Could anyone solve this programming problem?

Mar 22 2005 8:19 PM
I am trying to develop an application that calculates a set of requirements and then matches them to a case. For example: My system may calculate the following requirement based upon user inputs: RQ1 1782 RQ2 70 RQ3 80 RQ4 80 So there are four parts(RQ1-RQ4) that make up a requirement. Also in my system i have an array that stores the different options that may meet these requirements. The array is 2D, the first element is the identifier, and the remaining four are of the same type as RQ1-RQ4. My array looks something like this: Case_Data{{"A", 105, 4, 4.04, 4.03}, {"B", 120, 5.55, 4.7, 4.74},{"C", 152, 6.38, 6.02, 4.23}, etc There are 7 records in the array, A-G. My problem is that i need to determine which of the cases from the array can best match the RQ1 requirement. What i mean by 'best match' is which Case can get nearest to the values calculated and stored in variables RQ1-RQ4 through a simple integer multiplication. I can probably best explain via an example. Take our Requirement above, RQ1-RQ4, we have the values 1782, 70, 80 , 80. Using Case 1 if we multiply continually by integer numbers until we are less than 50 away from the RQ1 value(1782), we find we have to multiply 17 times, this gives us 1785, which is only 3 away. We then multiply RQ2-RQ4 by 17 to give us: 1785, 68, 68.68, 68.68 Now if we try the same process using Case 2 we multiply by 14 and get 1680, or 15 and get 1800, if we are not less than 50 we take the higher value, therefore 1800. We can see that case 1 is a better match and so the application shold suggest using case 1 instead of Case2. Can anyone suggest a starting point for me to do this, i really have no idea, i've managed to get my Requirement calculator working and now need this 'selection' process to help complete this section of my application.