Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions