Sum and Average with forEach
mediumQuestion 104You can use forEach together with a variable that lives outside the loop to build up a running total. You are given an array of grades. Use forEach to add every grade into a total, then print "Sum: " followed by the total, and on the next line print "Average: " followed by the total divided by the number of grades.
Expected output
Sum: 340 Average: 85
= newline. The output ends with a newline, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
Arrays
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (clog, fn, fori)
Your output
Run your code to see the output here...
Test cases
Run your code to see test case results.