Q:

Getting a proper decimal in Java?

I'm doing
double x = distance/maxRange;

And want x to be equal to 1/3 for example when distance = 10 and maxRange = 30 instead of 0.  
How do I got about having it properly formatted?
Thanks.

A:

double  x =  (double) 1/3;
System.out.println(x); // result print 0.3333333333333333

You must convert your calculation to double, else you will get 0.

