First of all, good morning, everyone!
Well today I have a small problem to solve with a program that I am asked to develop in Java is to calculate the figure in mileage that a car should be maintenance . For example, each vehicle is serviced at 5,000 Km . Which means that a car with a current mileage of 10,000 Km must go to maintenance at 15,000 Km . The alerts will be sent according to the value of the current mileage field. But my teacher wants to see a field that shows the mileage in which the car should go to maintenance in base at 5000 Km . Example:
-
Auto: Toyota Corolla
-
Board: A121212
-
Km Current: 5500
-
KmProxMaintenance: ? Here I show my interface what is enclosed in Red is the data that I use static to calculate when it has already traveled the 5000 km.
5000 in the red circle is the basis for calculating the 5000 km route and sending the alerts but as I said before, the teacher wants to see the next mileage according to the current mileage or how I have set it KmFinal
This is my code:
@FXML
public void RE() {
try {
Integer n1 = Integer.parseInt(txt_KmIni.getText());//Kilometraje Inicial de la jornada
Integer n2 = Integer.parseInt(txt_KmFin.getText());//Kilometraje Final fin de jornada
Integer resta1 = n2 - n1;//Resta de Kilometraje final menos inicial = Kilometraje Recorrido durante la jornada
String total1 = Integer.toString(resta1);
txt_KmRec.setText(String.valueOf(total1)); //Total asignado al campo Kilometraje Recorrido
Integer Recorrido = Integer.parseInt(txt_KmRec.getText()); //Campo Kilometraje recorrdio
Integer RecorridoTtal = Integer.parseInt(txt_KmRecoTotal.getText());//Campo Kilometraje Recorrido Total por cada vahiculo Proviene de suma en MySQL
Integer ProxMantenimiento = Integer.parseInt(txt_ProxMant.getText());//Campo con valor de proximo mantenimiento en este caso 5,000 como base
Integer Calculado1 = Recorrido + RecorridoTtal; //Recorrido del dia + Recorrido Total del vehiculo -> (Dato de MySQL)
Integer Calculado2 = ProxMantenimiento - Calculado1;//Resta del campo Proximo Mantenimiento - Calculado1 que es la suma del kilometraje recorrido del dia mas el total del vehiculo
txt_KmRest.setText(String.valueOf(Calculado2)); //Aqui es donde seteo el resultado de Calculado2 que es el kilometraje restante para el proxmantenimiento segun esto envio alertas.
} catch (Exception e) {
}
}