Average Mark from a File (Form Designer)

Grade 12

This is a form-based problem — open it in the Form Designer, not the code judge. A data file, Details.txt, lists one learner per line in the format '<Name>#<Mark>'. A button (btnAverage) and a panel (pnlAverage) are already on the form. Write btnAverage's OnClick handler so that it reads the whole file, works out the average mark across every learner, and shows it on pnlAverage, rounded to the nearest whole number. Your code must work for any number of lines in the file, not just five.

No input/output in the console sense. Grading clicks btnAverage once, then checks pnlAverage.Caption. Details.txt: Erinn Stansell#87 Michael Dinjes#90 Gabrielle Wadhams#23 Mirelda Berendsen#47 Elmore Skalls#32 Expected output: '56' (279 / 5 = 55.8, rounded to 56).

Provided data file

Details.txt

Erinn Stansell#87
Michael Dinjes#90
Gabrielle Wadhams#23
Mirelda Berendsen#47
Elmore Skalls#32
Average Mark─ ▢ ✕
Average
Average mark:

3 components · drag to move, corner handle to resize, Delete to remove

Object Inspector

Select a component on the form to edit its properties.

Palette

Pick a component, then click the form

Standard

Additional

Data

Non-visual