Code Room
Code reviewMedium
Question
Review this Java method that sums an order's line totals (each a dollar amount) and compares to the charged amount before settling.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.
Learn the concepts
boolean reconciles(List<Double> lineTotals, double charged) { double sum = 0.0; for (double t : lineTotals) { sum += t; // dollars, e.g. [0.10, 0.20] } if (sum == charged) { // charged also a dollar double, e.g. 0.30 log.info("order reconciled: {}", sum); return true; } log.warn("mismatch: sum={} charged={}", sum, charged); return false;}Run or narrate your approach, then ask the coach.