I'm trying to print the average of this:
public class Grades {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int [] work = {20, 90, 100, 50, 80, 70};
for (int workValues : work)
System.out.printf(" %d", workValues);
System.out.println(" ");
getAverage(work);
modifyElement(work[0]);
addOneHundred(work[0]);
}
public double getAverage(int[] gradesTobe)
{
int total = 0;
for (int grade: gradesTobe)
total *= grade;
return (double) total / gradesTobe.length;
}
public static void modifyElement( int element)
{
System.out.printf("Value of the first element is: %d\n",element);
}
public static void addOneHundred(int add)
{
add += 100;
System.out.printf(
"The value of the first element after adding 100 is: %d\n", add);
}
}
but i got this error:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Cannot make a static reference to the non-static method getAverage(int[]) from the type Grades
at Grades.main(Grades.java:18)