Why no output here

Here's some simple code I'm working on but I can't get the mean to display. Everything compiles correctly but the "Mean will not display. What did I do wrong?

// Two-dimensional array to store grade data.

publicclass Gradebook

{

privateint grades[][];// two-dimensional array of student grades

//constructor initializes grades array

public Gradebook( String name,int gradesArray[][] )

{

grades = gradesArray;// store grades

}// end GradeBook constructor

// perform various operations on the data

publicvoid processGrades()

{

// output grades array

// call methods getMinimun, getMaximum, getMean, getMode

System.out.printf("\n%s %d\n%s %d\n\n",

"Lowest grade is", getMinimum(),

"Highest grade is", getMaximum(), getMean());

}

// end method processGrades

// find minimum grade

publicint getMinimum()

{

// assume first element of grades array is smallest

int lowGrade = grades[ 0 ][ 0 ];

// loop through rows of grades array

for (int studentGrades[] : grades )

{

// loop through columns of current row

for (int grade : studentGrades )

{

// if grade less than lowGrade, assign it to lowGrade

if ( grade < lowGrade )

lowGrade = grade;

}// end inner for

}// end outer for

return lowGrade;// return lowest grade

}// end method getMinimum

// find maximum grade

publicint getMaximum()

{

// assume first element of grades array is largest

int highGrade = grades[ 0 ][ 0 ];

// loop through rows of grades array

for (int studentGrades[] : grades )

{

// loop through columns of current row

for (int grade : studentGrades )

{

// if grade greater than highGrade, assign it to highGrade

if ( grade > highGrade )

highGrade = grade;

}// end inner for

}// end outer for

return highGrade;// return highest grade

}// end method getMaximum

// find Mean

publicdouble getMean ()

{

int rows =0;

int cols =0;

int i, j, num;

double mean, total = 0.0;

// Find the sum of all the elements

for (i = 0; i < rows; i++)

{

for (j = 0; j < cols; j++)

{

total += grades[i][j];

}

}

// Calculate number of elements

num = rows * cols;

// Find the mean

mean = total/num;

System.out.printf("The Mean is", + mean);

return mean;

}

}// end class GradeBook

The "test code" is here:

/// Creates GradeBook object using an array of grades.

publicclass GradebookTest

{

// main method begins program execution

publicstaticvoid main( String args[] )

{

// two- dimensional array of student grades

int gradesArray[] [] ={{88,99,89,88,77},// Student 1

{98,75,66,89,65},//Studen 2

{90,89,70,78,100},//Student 3

{94,74,86,89,63},//Student 4

{99,76,99,89,64},// Student 5

{89,76,89,88,56},// Student 6

{98,76,89,88,99},//Student 7

{98,89,66,88,89}};//Student 8

Gradebook myGradebook =new Gradebook

("", gradesArray);

// myGradebook.displayMessage();

myGradebook.processGrades();

}// end main

}// end class GradeBookTest

[7609 byte] By [mrb62a] at [2007-11-27 7:52:24]
# 1
Check that format descriptor very closely in the printf() call, in that top block of code.
kevjavaa at 2007-7-12 19:33:38 > top of Java-index,Java Essentials,New To Java...
# 2
Worst comments. Ever.
Hippolytea at 2007-7-12 19:33:38 > top of Java-index,Java Essentials,New To Java...
# 3
Well, you don't have to getMean() about it. ;)
kevjavaa at 2007-7-12 19:33:38 > top of Java-index,Java Essentials,New To Java...
# 4

<Check that format descriptor very closely in the printf() call, in that top block of code.

I actually copied that printf from somewhere else when I couldn't get anything to display. I don't really know what most of it means but I know it helped some. I know \n means newline but the rest of the characters confuse me.

Now I get this which is a little better

"The Mean is

Lowest grade is 56

Highest grade is 100">

mrb62a at 2007-7-12 19:33:38 > top of Java-index,Java Essentials,New To Java...
# 5
<Worst comments. Ever.Cause I'm the worst programmer ever.>
mrb62a at 2007-7-12 19:33:38 > top of Java-index,Java Essentials,New To Java...
# 6

Go here, and read about the wonders that are printf() and the syntax of its format specifiers :).

http://java.sun.com/j2se/1.5.0/docs/api/java/util/Formatter.html#syntax

http://java.sun.com/j2se/1.5.0/docs/api/java/io/PrintWriter.html#printf(java.util.Locale,%20java.lang.String,%20java.lang.Object...)

%s == string

%d == decimal (integral)

%f == floating point

kevjavaa at 2007-7-12 19:33:38 > top of Java-index,Java Essentials,New To Java...
# 7
Why is my mean method not calculating? Is my code correct for finding the mean?
mrb62a at 2007-7-12 19:33:38 > top of Java-index,Java Essentials,New To Java...
# 8
> Why is my mean method not calculating? Is my code> correct for finding the mean?Why not rewrite your getMean method to follow the pattern of the other two.Or answer this question: what are the values of rows and cols in getMean?
Hippolytea at 2007-7-12 19:33:38 > top of Java-index,Java Essentials,New To Java...
# 9
You must have forgot that I'm the worst programmer ever. The value of the rows and cols are equal to the sum of the grades array... I thought.
mrb62a at 2007-7-12 19:33:38 > top of Java-index,Java Essentials,New To Java...
# 10
sorry if im too naive :( ...where are the cols,rows variables been assigned with values in getmean() method .. when they are '0' , control would not go into first for loop itself ...
krishna_kanth83a at 2007-7-12 19:33:38 > top of Java-index,Java Essentials,New To Java...