double a = 47, b = 94; for (;; a += .5, b -= .5) { if (a == b) { System.out.println(a); break; } }