Loading...
Loading...
Loading...
A class teacher has the marks of every student in one test. Find the total of all marks and the class average.
Example
Input
5 72 85 64 90 58
Output
369 73.80
72 + 85 + 64 + 90 + 58 = 369, and 369 / 5 = 73.80.
Try the problem first. Open one hint at a time.
Read the marks into an array with a loop, then add them up with a second loop.
Divide as a double, not as an int, or 369 / 5 becomes 73.
Use printf with %.2f to print exactly two digits after the point.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor