Question: What is the range of possible values for the variable x? (2 points) int x = (int)(Math.random() * 10); 0

What is the range of possible values for the variable x? (2 points)

int x = (int)(Math.random() * 10);

0 <= x < 1

0 <= x <= 1

0 <= x < 9

0 <= x <= 9

1 <= x < 10

A large quantity of purple and yellow stones are placed in a bag. There is a 40 percent chance of drawing a purple stone. Write the section of code to simulate randomly picking 20 stones from the bag and reporting the color of each.

How many times will the following while loop repeat? (2 points)

int flipCount = 0;

while(flipCount < 10)

{

// code not shown

flipCount++;

}

0

1

9

10

11

The intent of the following code segment is to simulate flipping a coin five times. What happens when the code is run? (2 points)

int flipCount = 1;

while(flipCount < 5)

{

//code not shown

flipCount++;

}

An infinite loop occurs.

The code block within the while is not executed.

The loop iterates one too few times.

The loop iterates one too many times.

The code segment works as intended.

Given the following code segment, which of the expressions could take the place of to cause 10 iterations of the while loop? (2 points)

int flipCount = 0;

while( )

{

// code not shown

flipCount++;

}

I. flipCount < 10

II. flipCount < 9

III. flipCount != 10

I only

II only

III only

I and II only

I and III only

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 Programming Questions!