Implementing Selection and Iteration Algorithms FRQ Practice

Responses receive AI feedback against a rubric after submission. Scores are practice estimates.

Question 1 of 5

Contract: Input.readInt() reads the next integer the user types and returns it as int. Each call consumes one integer. Remembering Scanner method names is not required. A packing line groups items by fours.

(a) Write Java that stores the next typed integer in n, then prints box if n is divisible by 4 and loose otherwise. (b) If the user types 12, state the displayed text. (c) Explain why % is the operator that tests exact groups of 4.

Question 2 of 5

Complete the missing cells for this right-to-left digit walk. Then state the full displayed text.

int n = 613;
while (n > 0) {
    System.out.print(n % 10);
    n /= 10;
}
After this pass n % 10 printed n after n /= 10
first
second
third

Question 3 of 5

A teacher wants the count of integers from 1 through 20 that are divisible by 5.

(a) Write a for loop that stores that count in an int named hits. (b) State the final value of hits. (c) Explain the job of the if test inside the loop.

Question 4 of 5

Contract: Input.readInt() reads the next integer the user types and returns it as int. Each call consumes one integer. Remembering Scanner method names is not required. Four scores are typed in this order: 8, 15, 3, 11.

(a) Write Java that reads those four integers and stores the largest in an int named biggest, using a scalar starter and later updates. (b) State the final value of biggest. (c) Explain why initializing biggest from the first read is valid.

Question 5 of 5

Even lane numbers from 2 through 10 inclusive are totaled, then averaged with int division.

(a) Write a loop that stores the sum in total and the term count in howMany, then prints total / howMany. (b) State the sum and the printed average. (c) Explain why the printed average is not 6.0 as a decimal token.