S
stu
I tried with setMinimumFractionDigits(int) (from
java.text.NumberFormat) to get 22.22 of 22.222221.
I tried it on the double variable as well as after the double has been
converted to string. What am I doing wrong? Here is my code:
Note that FahrenheitDegree was declared as int.
Double celsiusDegree = (5 * (( (double) FahrenheitDegree - 32)/9) );
Double cs = celsiusDegree.setMinimumFractionDigits(2);
String celsiusString = new Double(cs).toString();
//String cstr = celsiusString.setMinimumFractionDigits(2);
String message = String.format(FahrenheitString + " degree Fahrenheit =
%s degree Celsius.", celsiusString);
//String message = String.format(FahrenheitString + " degree Fahrenheit
= %s degree Celsius.", cstr);
java.text.NumberFormat) to get 22.22 of 22.222221.
I tried it on the double variable as well as after the double has been
converted to string. What am I doing wrong? Here is my code:
Note that FahrenheitDegree was declared as int.
Double celsiusDegree = (5 * (( (double) FahrenheitDegree - 32)/9) );
Double cs = celsiusDegree.setMinimumFractionDigits(2);
String celsiusString = new Double(cs).toString();
//String cstr = celsiusString.setMinimumFractionDigits(2);
String message = String.format(FahrenheitString + " degree Fahrenheit =
%s degree Celsius.", celsiusString);
//String message = String.format(FahrenheitString + " degree Fahrenheit
= %s degree Celsius.", cstr);