Question #111891

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

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

System.out.println( (int)Math.random()*4 + 5 ); _________________

System.out.println( (int)(Math.random()*50) );

Expert's answer

System.out.println( (int)(Math.random()*5) + 3 ); // int from 3 to 8

System.out.println( (int)Math.random()*4 + 5 ); //always int 5

System.out.println( (int)(Math.random()*50) ); // int from 0 to 50  

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