Hi guys I need some help with calculating and displaying a ratio result.
so here is the sample code I am working on:
double a = 11;
double b = 2508;
double total1;
double total2;
total1 = a / b;
System.out.println(total1);
Now the result I get is 0.0043859649122807015 . However I only need the "0.004" the three decimal places, and to calculate the ratio I will need to round "0.004" in to 1 so how do I do that?
Phase2
double a = 11;
double b = 2508;
double total1;
double total2;
total1 = a / b;
System.out.println(total1);
total2 = 1/total1; //1 is equal a rounded 0.004 then devided by 0.004
System.out.println(total2);
But I had to manually put 1 to do the calculation. is there a way to store total 1 from the first calculation? total1 = a/b; . So I can call it back to do a "total2 = "A rounded 1 of 0.004"/total1;
Finally print the result out and is 250.
Little formula
11/2508 = 0.004
0.004 = 1
1/0.004= 250
1:250
I have tried to use decimalformat on j2me but it does not support it