The first problem is easy to solve, just follow the output.
The second problem is a formula in which variables store numbers.
The third question, you can combine your student number, name and grades into strings, and then sort them according to the average grades, which is a good solution.
You can find a writing program according to your own ideas, which is easy to write.