AboveAvg

AboveAvg - int sum = 0 for(int j = 0 j<numGrades j...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
public class AboveAvg{ public static void main(String [ ] args){ // read grades, print those above the average of all grades read int numGrades = IO.readInt( ); if (numGrades <= 0){ IO.reportBadInput( ); } else { int[ ] grades = new int [numGrades];
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: int sum = 0; for (int j = 0; j<numGrades; j++){ grades[j] = IO.readInt( ); sum += grades[j]; } double avg = sum / (double) numGrades; for (int j = 0; j < numGrades; j++){ if (grades[j] > avg){ IO.outputIntAnswer(grades[j]); } } } } }...
View Full Document

This note was uploaded on 07/12/2009 for the course CS 111 taught by Professor Hari during the Fall '08 term at Rutgers.

Ask a homework question - tutors are online