Math Class FRQ Practice

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

Question 1 of 5

A climate log records signed errors.

(a) What is Math.abs(0)? Include the type. (b) What is Math.abs(-6.5)? Include the type. (c) Explain why (int) Math.abs(-6.5) is 6 rather than 7.

Question 2 of 5

(a) State Math.sqrt(16) with its type. (b) State Math.pow(4, 2) with its type. (c) Explain why assigning either result to an int variable requires a cast.

Question 3 of 5

A sprinkler program uses (int)(Math.random() * n) to pick a nozzle index.

(a) If n is 4, list every possible int result. (b) Explain the connection to Math.random() being [0, 1). (c) Write an expression for a double in [0.0, 4.0) with no shift.

Question 4 of 5

Night temperatures must be a random int from 12 through 15 inclusive.

(a) Write the Math.random expression. (b) Show the factor multiplied by Math.random(). (c) Explain a wrong expression (int)(Math.random() * 15) + 12.

Question 5 of 5

A tester substitutes 0.99 for Math.random().

int k = (int) (0.99 * 10);

(a) State k. (b) Explain whether this sample can be 10. (c) Explain how to include 10 as a possible int if the desired inclusive range is 0 through 10.