result = (mOp == OP.C2F) ? TemperatureConverter.celsiusToFarenheit(temp); TemperatureConverter.fahrenheitToCelsius(temp); final String resultString = String.format("%.2f", result); mDest.setNumber(result); mDest.setSelection(resultString.length()); } catch (NumberFormatException e) { // WARNING // this is generated while a number is entered, // for example just a '-' // so we don't want to show the error } catch (Exception e) { mSource.setError("ERROR: " + e.getLocalizedMessage()); } if ( BENCHMARK_TEMPERATURE_CONVERSION ) { long t = System.currentTimeMillis() - t0; Log.i(TAG, "TemperatureConversion took " + t + " ms to complete."); } }
1; final int b = 2; final int expected = b; final int actual = Math.max(a, b); assertEquals("Expection " + expected + " but was " + actual, expected, actual); }
and viceversa • Two fields to input data • When temperature is entered, other field updates • Error displayed • Some space reserved keyboard • Entry fields start empty • Digits right aligned • Last entered values retained after onPause()