Question #111890

What value(s) will be output by the following Java code statements?

System.out.println( Math.random() ); _________________

System.out.println( Math.random() * 3); _________________

System.out.println( (int)(Math.random()*10) + 2);

Expert's answer

System.out.println( Math.random() ); --> numbers ranging from 0.0 to 1.0 (double)

System.out.println( Math.random() * 3); --> numbers ranging from 0.0 to 3.0 (double)

System.out.println( (int)(Math.random()*10) + 2); --> numbers ranging from 2 to 10 (int)



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS