Essay
Assertions
For the following method, identify each of the three assertions in the table below as being either ALWAYS true, NEVER true or SOMETIMES true / sometimes false at each labeled point in the code. (can abbreviate as A/N/S)
public static int threeHeads() { // Counts coin tosses till we get heads 3x in a row.
Random rand = new Random();
int flip = 1;
int heads = 0;
int count = 0;
// Point A
while (heads < 3) {
// Point B
flip = rand.nextInt(2); // flip coin
if (flip == 0) { // heads
heads++;
// Point C
} else { // tails
// Point D
heads = 0;
}
count++;
}
// Point E
return count;
}
Correct Answer:

Verified
Correct Answer:
Verified
Q1: Programming<br>Write a static method named printTwoDigit
Q2: While Loop Simulation<br>For each call below
Q3: Parameter Mystery<br>At the bottom of the page,
Q4: If/Else Simulation<br>For each call below to
Q5: Expressions<br>For each expression in the left-hand
Q6: Programming<br>Write a static method named consecutiveDigits
Q7: Programming (15 points)<br>In this question, we'll address