rewrote the scanner of the java calculator example