I have to develop an algorithm that calculates the average speed of the orders that were delivered. This is calculated based on the production times and the number of units that each order has; but these are taken into account according to a date history delivered by the user from which they begin to consider the orders for the calculation.
It turns out that all the data come from an Excel file, so they are read in double
, but when running the program I get an error "NaN" (not a number), I do not understand what the problem is. Attached part of the code
Class method requested for speed calculation:
public double CalcularVelocidadL1(Date fechaHist){
llenarLista();//metodo que me llena la lista en la que voy a trabajar
double suma=0;
int cont=0;
NodoListaL1 aux= headL1;
while(aux.getNext()!=null){
if(aux.getNext().getDato().getFec_ped().after(fechaHist)|| aux.getNext().getDato().getFec_ped().equals(fechaHist)){
double num=aux.getNext().getDato().getUni_lot();
double den=aux.getNext().getDato().getTmp_proc();
double div=num/den;
suma=suma+div;
cont++;
}
}
aux=aux.getNext();
double vel=(suma/cont);
return vel;
}
Main method where the date is requested:
public static void main(String[]args)throws IOException, ParseException{
BufferedReader lector=new BufferedReader(new InputStreamReader(System.in));
LeerExcel excel=new LeerExcel();
excel.Leer();
System.out.println("ingrese fecha");
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
String f=lector.readLine();
Date fecha=sdf.parse(f);
ArraylistP v =new ArraylistP();
double d=v.CalcularVelocidadL1(fecha);
System.out.println(d);
}