I have been given a chunk of code from my teachers, and I just need help getting it to run. I'm very new to java so any help is much appreciated. Here it is:
import java.util.*;
import java.io.*;
public class CourseStats
{
static String[ ] studentNames;
static int[ ][ ] quizzes;
static int[ ][ ] homeworks;
static int[ ] exam;
static final int NUM_QUIZZES = 9;
static final int NUM_HOMEWORKS = 12;
static final int QUIZZES = 1;
static final int HOMEWORKS = 2;
public static void main(String[] args) throws IOException
{
initializeArrays( );
readFile( args[0] );
printDetails( );
printAverages( );
}
public static void printAverages( )
{
//NOTE - this loops from 1 (not 0) to the number of quizzes/homeworks - because we say "HW1" and "Q1"
// NOT HW0 and Quiz0. So, when you implement the method getAverage - take note of this - we're sending in i which
// starts at 1!!!!! Your index starts at zero!!
// Do not change our code - make your code work with this.
for ( int i=1; i<=NUM_QUIZZES; i++ )
{
System.out.print( "Quiz #" + i + " average: " );
System.out.println( getAverage( QUIZZES, i ) );
}
for ( int i=1; i<=NUM_HOMEWORKS; i++ )
{
System.out.print( "HW #" + i + " average: " );
System.out.println( getAverage( HOMEWORKS, i ) );
}
}
public static void printDetails( )
{
System.out.print( "Q1\tQ2\tQ3\tQ4\tQ5\tQ6\tQ7\tQ8\tQ9");
for ( int i=1; i<=12; i++ )
System.out.print( "\tHW" + i );
System.out.println( "\tEXAM\tName" );
}
public static double getAverage( int type, int whichOne )
{
if ( type == QUIZZES )
{
}
else if ( type == HOMEWORKS )
{
}
}
public static void initializeArrays( )
{
studentNames = new String[ 100 ];
quizzes = new int[100][NUM_QUIZZES];
homeworks = new int[100][NUM_HOMEWORKS];
exam = new int[100];
}
public static void readFile( String filename ) throws IOException
{
}
}
These are my errors:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
This method must return a result of type double
at CourseStats.getAverage(CourseStats.java:46)
at CourseStats.printAverages(CourseStats.java:31)
at CourseStats.main(CourseStats.java:18)