Hey i am using the following code to format my numbers to have two decimal places
public String format(double num)
{
String temp="";
DecimalFormat df=new DecimalFormat("R.##");
temp=temp+df.format(num);
return temp;
}
When I print out the results it gives me the answeres with only one decimal place. Please can someone help me stop that.
Use following way to format
You use
#
inDecimalFormat
which is the character that says "print the digit. if it is 0 leave it out."You need to use
0
where 0 is also printed as 0.E.g.
try this