I have this program and I declared a variable inside a for loop. Is this bad conventions? I declared it inside so that each time the variable is representing something else through each iteration, is this good?
import java.util.stream.IntStream;
public class Program {
public static boolean changeEnough(int[] change, double amountDue) {
double balance = 0;
double[] value = {0.25, 0.1, 0.05, 0.01};
for (int i=0;i <change.length; i++){
double temp = change[i] * value[i];
balance += temp;
}
if (balance >= amountDue){
return true;
}
else{
return false;
}
}
}