Code Room
Code reviewHardcr-g269
Subject RoundingLevel Senior–Staff~20 minCommon in Code quality & review interviewsIndustries Software development

Question

Review this Java code that splits an invoice total evenly across line items, in cents.

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.

Talk through your review
Code to reviewjava
long[] split(long totalCents, int parts) {    long[] out = new long[parts];    long each = (long) (totalCents / (double) parts);    for (int i = 0; i < parts; i++) {        out[i] = each;    }    return out;}
Run or narrate your approach, then ask the coach.