Which is the band where you have placed the "TOTAL" variable i.e. Column Footer, Page footer or Summary? What is the Reset type for the "TOTAL" variable (ideally it should be Report if in Summary Band)
The Variable Expression- ( $F{ID}== 1 || $F{ID}==3 ? $F{Number_of_Vehicles} : 0 ) or even
( $F{Type}== "Car" || $F{Type}== "Truck" ? $F{Number_of_Vehicles} : 0 ) should work for you.