Question 1 of 5
Fill in each value in the table. Then explain why the second and third results differ.
| Expression | Value |
|---|---|
| (int) 4.99 | ? |
| (double) 14 / 5 | ? |
| (int) (14 / 5) | ? |
Responses receive AI feedback against a rubric after submission. Scores are practice estimates.
Fill in each value in the table. Then explain why the second and third results differ.
| Expression | Value |
|---|---|
| (int) 4.99 | ? |
| (double) 14 / 5 | ? |
| (int) (14 / 5) | ? |
Write the usual expression that rounds a nonnegative double to the nearest int by adding 0.5 and casting. Evaluate that expression for 3.49 and for 3.50.
Trace this update. Give the mathematical result of subtracting 3, the Java int result, and explain why they differ.
int debt = Integer.MIN_VALUE + 1;
debt -= 3;
A loading dock estimates half a shipment. The intended value of half is 1400000000, which fits in an int. Explain why this code does not store that value, state the intended mathematical result, and write a corrected expression that avoids the overflowing product.
int packs = 70000;
int weight = 40000;
int half = packs * weight / 2;
A phone stores battery voltage as double volts = 3.7;. Explain why 3.7 may not be stored exactly. Name this kind of error. Give an int millivolt amount for 3.70 V that remains exact if all values and intermediate totals fit in an int.