5 Replies Latest reply: Nov 9, 2006 12:26 PM by 807607 RSS

    "class or interface expected" message when compiling - Should be easy fix

    807607
      I'm trying to write a fairly simple java applet, but am getting an error when adding in the calculation-segments. The problem is with the max or get_max, as its not declared properly or something. The applet is just a double array prompting the user to enter a student id, and exam marks. Then will be doing various calculations from there. Here is the code with just the highest mark calculation:
      import java.awt.*;
      import javax.swing.*;
      
      public class DoubleArray extends JApplet {
      
              int arr[][];
              String output;
              public void init()
              {
                      int i,j,the_size,numofcol;
      
              int counter=0, action, stNumber;
              JTextArea outputArea = new JTextArea();
              Container container = getContentPane();
      
              the_size = Integer.parseInt(getParameter("size"));
              numofcol = Integer.parseInt(getParameter("exam")) + 1;
      
              arr = new int[the_size][numofcol];
              for (i=0; i<the_size; i++)
                      {
                      arr[0] =
      Integer.parseInt(JOptionPane.showInputDialog("Enter student number "));
      for (j=1; j<numofcol; j++)
      {
      arr[i][j] = Integer.parseInt(JOptionPane.showInputDialog("Enter exam "+ j +" marks"));
      }
      }
      container.add(outputArea);
      output = "The Class Record" ;
      for (i=0; i<the_size; i++)
      {
      output += "\nStudent "+ arr[i][0] + "--";
      for (j=1; j<numofcol; j++)
      {
                output += arr[i][j] + " ";
      }
      }
      max=get_max(the_size,numofcol,arr);
      output += "\nHighest Mark is "+ max;
      outputArea.setText(output);
      } //end init

      public int get_max(int s, int c, int a[][])
      {
      int i,j,highest;
      highest = a[0][1];
      for (i=0; i<s; i++)
      for (j=1; j<c; j++)
      if (highest < a[i][j])
      highest = a[i][j];
      return highest;
      }
      }


      Any help or tip on where the problem lies would be appreciated. Thanks