Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1.Suppose that the chance to hit the jackpot in a lottery is one in one million.

ID: 3679966 • Letter: 1

Question

1.Suppose that the chance to hit the jackpot in a lottery is one in one million. Which of the following code snippets simulates that random number?

Select one:

a. (long) (Math.random() * 1000000 + 1)

b. (long) (Math.random() * 100000 + 1)

c. (long) (Math.random() * 9999990 + 1)

d. (long) (Math.random() * 1000001 + 1)

2.

Insert a statement that will correctly terminate this loop when the end of input is reached.

Select one:

a. stop;

b. done = 1;

c. exit;

d. done = true;

3.

How many times does the following loop execute?

Select one:

a. Exactly once

b. Exactly twice

c. Can't be determined

d. Always infinite loop

4.

Choose the loop that is equivalent to this loop.

Select one:

a.

b.

c.

d.

5.

When designing storyboards, it is a good idea to use different colors to

Select one:

a. Make it easy to distinguish between user input and program output.

b. Match the colors your program will use when it is finally designed.

c. Emphasize the difference between numbers and words.

d. Draw lines to divide up panels into different regions.

Explanation / Answer

1)
(long) (Math.random() * 1000000 + 1)

2)
done = true;

3)
Cant be determined

4)
double x = 0;
double s = 1;
for (int k = 1; s > 0.01; k++)
{
s = 1.0 / (k * k);
x = x + s;
}

5)
Make it easy to distinguish between user input and program output.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote