Loading...
Loading...
A teacher builds a report card from the marks register, then corrects some entries in the register and builds a revised card. The first card must keep the marks it was made with.
Write a class Scorecard with fields name and marks (an int[]). Its constructor Scorecard(String name, int[] marks) must store a copy of the array, not the caller's array. Add int total() and int best().
i v: set subject i (1-based) of the register to v.ORIGINAL name total best, then REVISED name total best.Example
Input
Asha 3 70 80 90 2 1 95 3 60
Output
ORIGINAL Asha 240 90 REVISED Asha 235 95
The original card keeps 70 80 90; the revised one is built from 95 80 60.
Try the problem first. Open one hint at a time.
Inside the constructor, make new int[marks.length] and copy the values in a loop.
this.marks = marks; stores the same array: a later change to the register shows up on the card.
Build the first card before applying the corrections, and the second one after.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor