How to write the code to the console

A program
A class has Random number of students....
They took an exam and got random scores from 1 to 100.

Write to the console:
the number of students in the classes
The number of students that passed (above 70)
The number of students that got average scores (between 50 and 69)
The number of students that failed
The scores of all the students....