The code for converting integr to float and convert to percentage

int posivitivecount=12;

int totalcount=40;

float percentage=(float)posivitivecount/totalcount*100;

Now the value is converted is a float, if you want to fix the decimal places, you have to use the one more method

DecimalFormat dec = new DecimalFormat(“###.#”);

import the method before you call. That is java.text.DecimalFormat,

after inserting this method, pass the float value and convert it to string, and then convert to integer. if positive not start with decimal , then add . and 0 to that.

you will get the result like 12.0, 12.9.. like that. To do that.

String positiverate=dec.format(percentage);
int pos=positiverate.lastIndexOf(“.”);
if(!positiverate.startsWith(“.”,pos))
positiverate=positiverate+”.0″;