I am learning java for Android. I write about multiple conditions. The code runs but always returns a number 0 when I choose a spinner is a "car". besides the "car" (Truck, Bus, Motorcycle) all running. is there something wrong with Short-circuit evaluation? or is there another problem?
if ((h>0 && (h<=10) && (vehicle.equals("car"))){
txtvalue.setText(String.valueOf(v1));
} else if ((h >10) && (h <=20) && (vehicle.equals("car"))){
txtvalue.setText(String.valueOf(v2));
} else if ((h >20) && (h <=30) && (vehicle.equals("car"))){
txtvalue.setText(String.valueOf(v3));
} else if ((h >30) && (h <=40) && (vehicle.equals("car"))){
txtvalue.setText(String.valueOf(v4));
} else if ((h >40) && (vehicle.equals("car"))){
txtvalue.setText(String.valueOf(v4));
} else if ( vehicle.equals("Truck")){
txtvalue.setText(String.valueOf(v5));
} else if ( vehicle.equals("Bus")){
txtvalue.setText(String.valueOf(v6));
} else if ( vehicle.equals("motorcycle")){
txtvalue.setText(String.valueOf(v7));
} else {
txtvalue.setText(String.valueOf(0));
}
no error appears
Aucun commentaire:
Enregistrer un commentaire