Question: Consider the following statement: int num = /* expression */; Which of the following replacements for /* expression */ creates in num a random integer

Consider the following statement:

int num = /* expression */;

Which of the following replacements for /* expression */ creates in num a random integer from 2 to 50, including 2 and 50?

a) (int)(Math.random() * 49) - 2

b) (int)(Math.random() * 50) - 2

c) (int)(Math.random() * 50) + 2

d) (int)(Math.random() * 49) + 2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!