Forget about programming
Get a pencil, some paper, and an eraser
write down, in English, how YOU would do this, step by step.
revise the above steps, getting more and more specific. eventually, you should get to the point where you could hand the directions off to an 8yr old child, and they could follow them.
only after you have done all the above should you consider writing a line of actual java.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
If Fred’s technique fails (it won’t, though), find said 8‑year‑and ask them how to do it.
You are supposed to do five things there. Total, count, average (I presume that means arithmetical mean), maximum and minimum. Do not attempt all five. Attempt one, get it working, then enhance your application by getting a second functionality working.
Another thing Fred often says is never to write more than 5 lines. Then you run the program in its current state, and see whether it works. it is much easier to divide it into little parts because you can find errors so much faster.