Computer Science, asked by Imaginator15, 7 months ago

A student incorrectly attempted to produce a random value in the range 1.6 using the expression.

6*( int) Math.random( ) + 1

Correct the error in expression above to get the desired result.

Please tell the correct answer
If I found any nonsense I will report the answer
And if your answer is useful I will follow you for sure....​

Answers

Answered by rohitkhajuria90
6

Explanation:

Range 1 to 6

6-Math.random()*5

Range 1 to 1.6

1+Math.random()*0.5

Exactly 1.6

6*( int) Math.random( ) + 1. 6

Range 1.0 to 1.9

1+Math.random()

To get rounded of value use the math.round()

Math.round((1+Math.random()*0.5) *10)/10.0

Similar questions