...

/

Solution Review: Find the Top Scorer in a Class

Solution Review: Find the Top Scorer in a Class

Have a look at the solution to the 'Find the Top Scorer in a Class' challenge.

Rubric criteria

Solution

Press + to interact
class Maximum
{
public static void main(String args[])
{
int[] array = {34, 2, 7, 12}; // Creating an array to store students' marks
System.out.println(Max(array)); // Passing the array to the Max function
}
// Function to find maximum value from array
public static int Max(int array[])
{
int max = 0; // Keeping track of max value
for(int i = 0; i < array.length; i++) // Traversing array till the end
{
if (max < array[i]) // If value is greater than max
{
max = array[i]; // Update max
}
}
return max;
}
}

Rubric-wise

...