I can give you the solution of the first problem.
The following method will help you to do precision upto any digits--
float getPrecisionRound (float value, int precision)
{
String sPattern = "####.0";
for (int i=1;i<precision ; i++)
sPattern += "0";
java.text.DecimalFormat df
= new java.text.DecimalFormat(sPattern);
return Float.parseFloat (df.format(value));
}
So u call this method as --> getPrecisionRound (1.23456,3)
Output ==> 1.234