tags:

views:

31

answers:

1

I got an exception "Unable to parse 53.6 as an integer". What is the proper format?

double dbval;
double temp_val=12;
double p = 1.8;
double fvalue =p;
temp_val = temp_val * fvalue;
temp_val = (temp_val + 32);
String dbcal1=Double.toString(temp_val);
dbval = Integer.parseInt(dbcal1);

System.out.println("dbval"+dbval);
+2  A: 

You can't parse 53.6 as an integer because it is not an integer.

If you are just trying to change temp_val to an integer there is no need to convert it to a string and back. You can cast use a cast instead:

int result = (int)temp_val;
Mark Byers