Loading...
Loading...
Before results go out, the exam cell tries moderation on a copy of the batch. A batch has score cards, and each card has a student's test scores. BONUS b adds b to every score in the copy (at most 100); FIX name t v sets test t of that student to v in the copy. Make the copy fully deep, then print each student's real and what-if totals and how many students changed.
BONUS b or FIX name t v.<name>: real <total>, what-if <total> for each student in input order, then Changed students: <k>.Example
Input
2 2 Diya 80 90 Arjun 70 65 2 BONUS 5 FIX Arjun 2 70
Output
Diya: real 170, what-if 180 Arjun: real 135, what-if 145 Changed students: 2
After the bonus Arjun has 75 and 70; the fix sets test 2 to 70, so 145.
Try the problem first. Open one hint at a time.
Three levels: the Batch, its ScoreCard[], and each card's int[]. Every level must be copied.
ScoreCard's copy constructor clones its scores; Batch's copy constructor makes a new array of new ScoreCard(...).
Find the student for FIX with a loop and equals on the name.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor