So this is my program which is linked to a driver program. I am having the problem possible lossy conversion and I understand where I am having it but I do not know how to fix it. I need to re-arrange a Double[] array = new Double[20]
by ordering the numbers from lowest to highest as shown below. How can I do this correctly with out making significant changes to my program?
public void insert (double val){
if(count < 20){
if(val >= 1 || val <= 10){
array[count] = val;
count++;
}
}
}
double min;
double max;
double tmp;
for(min = count - 1; min > 0; min--){
max = 0;
for(int i = 1; i <= min; i++){ // Error here because of the min value
if(val[i] > val[max]){ // Error here because of the max value
max = i;
}
}
if(max != min){
tmp = val[max]; // Error here because of the max value
val[max] = val[min]; // Error here because of the min value
val[min] = tmp; // Error here because of the min value
}
}