Hi. Sorry, if this is a really easy to answer.
I need to find the smallest int result in a calculation between a fixed value and a variable. Then I need to return one of those variable. However, if there exists multiple smallest results, then I return a fixed value.
Here's sort of a pseudo-code that doesn't work because sometimes it returns the "fixed_value" even though it's not the smallest result.
It also doesn't return "fixed_value" when it should.
String[] variable = { num0 , num1 , num2 , num3 };
int multiple_smallest = 0;
for (int i = 0 ; i < s.length ; i++) {
int result = calculation( fixed_value, variable[i] );
if ( result < smallest ) {
smallest = result;
String variable = s[i];
}
else if ( dist == smallest ) multiple_smallest++;
}
if ( variable == s[0] ) variable = "some_value0";
else if ( variable == s[1] ) variable = "some_value1";
else if ( variable == s[2] ) variable = "some_value2";
else if ( variable == s[3] ) variable = "some_value3";
if ( multiple > 0 ) variable = "fixed_value";
return variable;