QUOTE(Stoughty @ 2 Feb, 2008 - 06:09 PM)

QUOTE(PennyBoki @ 2 Feb, 2008 - 01:41 PM)

Hi Stoughty, what seems to be the problem with the code? A for loop? OK what about it? Feel free to post the question

Hey, well I'm not quite sure how to find the highest number contained in that loop, or the second highest number. How would I go about pulling that information from the current coding?
Well for the highest grade right after the input is taken have an 'int max' be set to the value of that number. Then after each sequential iteration of the loop have it check if the newest entry is higher then the previous max value such as:
CODE
int max = 0; //declaration
//your loop code .....
//your input line here
if (currentEntry > max)
max = currentEntry
//So on and so forth at the end max will contain the highest number entered
//print out max or w/e you need to do here
edit: Alternately you can declare an array and simply sort it after all input is finished and return the last two slots of the array.
CODE
Array[] studentGrades = new Array [numberOfStudents];
Arrays.sort(studentGrades);
//etc....
--KYA
This post has been edited by KYA: 2 Feb, 2008 - 04:47 PM