IPB

Welcome Guest ( Log In | Register )

> '.class' Expected Error
Bilun
post May 26 2005, 06:18 PM
Post #1


Newbie
*

Group: Members
Posts: 1
Joined: 26-May 05
Member No.: 865



hey i'm currently working on a project running various quadratic sorting algorithms and counting the number of steps each uses, however i've run into a small roadblock.

CODE for main file:
QUOTE
import java.awt.geom.*;
import java.util.*;
import apcslib.*;       
import chn.util.*;

public class epilcher_quadratics
{
public static void main(String[] args)
{
  int[] list100 = new int[100];
  int[] list200 = new int[200];
  int[] list400 = new int[400];
  int[] list800 = new int[800];
 
  int[] newList100 = new int[100];
  int[] newList200 = new int[200];
  int[] newList400 = new int[400];
  int[] newList800 = new int[800];
 
  Random die=new Random();
  quadratics q1 = new quadratics();
  general gen1=new general();
 
  int bubble100, bubble200, bubble400, bubble800, selection100, selection200, selection400, selection800, insertion100, insertion200, insertion400, insertion800;
 
// *************************************************************************************
 
  for (int x=0; x<100; x++)
  {
  list100[x]=die.nextInt(200)+1;
  }
  for (int x=0; x<200; x++)
  {
  list200[x]=die.nextInt(400)+1;
  }
  for (int x=0; x<400; x++)
  {
  list400[x]=die.nextInt(800)+1;
  }
  for (int x=0; x<800; x++)
  {
  list800[x]=die.nextInt(1600)+1;
  }
 
// *************************************************************************************
 
  for (int x=0; x<100; x++)
  {
  newList100[x]=list100[x];
  }
 
  bubble100=q1.bubbleSort(newList100[]);
 
  for (int x=0; x<100; x++)
  {
  newList100[x]=list100[x];
  }
 
  selection100=q1.selectionSort(newList100[]);
 
  for (int x=0; x<100; x++)
  {
  newList100[x]=list100[x];
  }
 
  insertion100=q1.insertionSort(newList100[]);
 
// *************************************************************************************
 
  for (int x=0; x<200; x++)
  {
  newList200[x]=list200[x];
  }
 
  bubble200=q1.bubbleSort(newList200[]);
 
  for (int x=0; x<200; x++)
  {
  newList200[x]=list200[x];
  }
 
  selection200=q1.selectionSort(newList200[]);
 
  for (int x=0; x<200; x++)
  {
  newList200[x]=list200[x];
  }
 
  insertion200=q1.insertionSort(newList200[]);
 
// *************************************************************************************
 
  for (int x=0; x<400; x++)
  {
  newList400[x]=list400[x];
  }
 
  bubble400=q1.bubbleSort(newList400[]);
 
  for (int x=0; x<400; x++)
  {
  newList400[x]=list400[x];
  }
 
  selection400=q1.selectionSort(newList400[]);
 
  for (int x=0; x<400; x++)
  {
  newList400[x]=list400[x];
  }
 
  insertion400=q1.insertionSort(newList400[]);
 
// *************************************************************************************
 
  for (int x=0; x<800; x++)
  {
  newList800[x]=list800[x];
  }
 
  bubble800=q1.bubbleSort(newList800[]);
 
  for (int x=0; x<800; x++)
  {
  newList800[x]=list800[x];
  }
 
  selection800=q1.selectionSort(newList800[]);
 
  for (int x=0; x<800; x++)
  {
  newList800[x]=list800[x];
  }
 
  insertion800=q1.insertionSort(newList800[]);
 
// *************************************************************************************

System.out.println("# of integers:      100      200      400      800");
System.out.println("--------------------------------------------------");
System.out.println("Bubble Sort:"+Format.right(bubble100, 11));
}
}




code for quadratic class:
QUOTE
import java.awt.geom.*;
import java.util.*;
import apcslib.*;       
import chn.util.*;


public class quadratics
{
int steps, min, temp;
public quadratics()
{
}

public int bubbleSort (int[] list)
{
  steps=0;
  steps++; 
  for (int outer = 0; outer < list.length - 1; outer++)
  {
  steps += 3;
      for (int inner = 0; inner < list.length - outer - 1; inner++)
      {
      steps += 3;
      if (list[inner] > list[inner+1])
      {
          int temp = list[inner];
          list[inner] = list[inner + 1];
          list[inner + 1] = temp;
          steps += 3; 
        }
      }
  }
  return steps;
  }
 
  public int selectionSort(int[] list)
  {
  steps=0;
  steps++;
  for (int outer=0; outer < list.length - 1; outer++)
  {
    min=outer;
    steps+=4;
    for (int inner = outer + 1; inner < list.length; inner++)
  {
    steps+=3;
    if (list[inner] < list[min])
      {
        min = inner;
        steps++;
      }

  }
  temp = list[outer];
      list[outer] = list[min];
      list[min] = temp;
      steps+=3;
  }
  return steps;
  }
 
  public int insertionSort(int[] list)
{
  steps=0;
  steps++;
    for (int outer = 1; outer < list.length; outer++)
  {
      int position = outer;
      int key = list[position];
      steps+=5;
      while (position > 0 && list[position - 1] > key)
      {
      list[position] = list[position - 1];
      position--;
      steps+=3;
      }
      list[position] = key;
      steps++;
    }
    return steps;
}


}




the errors are:
QUOTE
\\rabbit2\students\10000\10281\new java folder\eli's turn in folder\chapter 23\epilcher_quadratics\epilcher_quadratics.java:52: '.class' expected
  bubble100=q1.bubbleSort(newList100[])));
                                                    ^
\\rabbit2\students\10000\10281\new java folder\eli's turn in folder\chapter 23\epilcher_quadratics\epilcher_quadratics.java:52: ')' expected
  bubble100=q1.bubbleSort(newList100[])));
                                                      ^
\\rabbit2\students\10000\10281\new java folder\eli's turn in folder\chapter 23\epilcher_quadratics\epilcher_quadratics.java:59: '.class' expected
  selection100=q1.selectionSort(newList100[]);
                                                          ^
\\rabbit2\students\10000\10281\new java folder\eli's turn in folder\chapter 23\epilcher_quadratics\epilcher_quadratics.java:59: ')' expected
  selection100=q1.selectionSort(newList100[]);
                                                          ^
\\rabbit2\students\10000\10281\new java folder\eli's turn in folder\chapter 23\epilcher_quadratics\epilcher_quadratics.java:66: '.class' expected
  insertion100=q1.insertionSort(newList100[]);
                                                          ^
\\rabbit2\students\10000\10281\new java folder\eli's turn in folder\chapter 23\epilcher_quadratics\epilcher_quadratics.java:66: ')' expected
  insertion100=q1.insertionSort(newList100[]);
                                                          ^
\\rabbit2\students\10000\10281\new java folder\eli's turn in folder\chapter 23\epilcher_quadratics\epilcher_quadratics.java:75: '.class' expected
  bubble200=q1.bubbleSort(newList200[]);
                                                    ^
\\rabbit2\students\10000\10281\new java folder\eli's turn in folder\chapter 23\epilcher_quadratics\epilcher_quadratics.java:75: ')' expected
  bubble200=q1.bubbleSort(newList200[]);
                                                    ^
\\rabbit2\students\10000\10281\new java folder\eli's turn in folder\chapter 23\epilcher_quadratics\epilcher_quadratics.java:82: '.class' expected
  selection200=q1.selectionSort(newList200[]);
                                                          ^
\\rabbit2\students\10000\10281\new java folder\eli's turn in folder\chapter 23\epilcher_quadratics\epilcher_quadratics.java:82: ')' expected
  selection200=q1.selectionSort(newList200[]);
                                                          ^
\\rabbit2\students\10000\10281\new java folder\eli's turn in folder\chapter 23\epilcher_quadratics\epilcher_quadratics.java:89: '.class' expected
  insertion200=q1.insertionSort(newList200[]);
                                                          ^
\\rabbit2\students\10000\10281\new java folder\eli's turn in folder\chapter 23\epilcher_quadratics\epilcher_quadratics.java:89: ')' expected
  insertion200=q1.insertionSort(newList200[]);
                                                          ^
\\rabbit2\students\10000\10281\new java folder\eli's turn in folder\chapter 23\epilcher_quadratics\epilcher_quadratics.java:98: '.class' expected
  bubble400=q1.bubbleSort(newList400[]);
                                                    ^
\\rabbit2\students\10000\10281\new java folder\eli's turn in folder\chapter 23\epilcher_quadratics\epilcher_quadratics.java:98: ')' expected
  bubble400=q1.bubbleSort(newList400[]);
                                                    ^
\\rabbit2\students\10000\10281\new java folder\eli's turn in folder\chapter 23\epilcher_quadratics\epilcher_quadratics.java:105: '.class' expected
  selection400=q1.selectionSort(newList400[]);
                                                          ^
\\rabbit2\students\10000\10281\new java folder\eli's turn in folder\chapter 23\epilcher_quadratics\epilcher_quadratics.java:105: ')' expected
  selection400=q1.selectionSort(newList400[]);
                                                          ^
\\rabbit2\students\10000\10281\new java folder\eli's turn in folder\chapter 23\epilcher_quadratics\epilcher_quadratics.java:112: '.class' expected
  insertion400=q1.insertionSort(newList400[]);
                                                          ^
\\rabbit2\students\10000\10281\new java folder\eli's turn in folder\chapter 23\epilcher_quadratics\epilcher_quadratics.java:112: ')' expected
  insertion400=q1.insertionSort(newList400[]);
                                                          ^
\\rabbit2\students\10000\10281\new java folder\eli's turn in folder\chapter 23\epilcher_quadratics\epilcher_quadratics.java:121: '.class' expected
  bubble800=q1.bubbleSort(newList800[]);
                                                    ^
\\rabbit2\students\10000\10281\new java folder\eli's turn in folder\chapter 23\epilcher_quadratics\epilcher_quadratics.java:121: ')' expected
  bubble800=q1.bubbleSort(newList800[]);
                                                    ^
\\rabbit2\students\10000\10281\new java folder\eli's turn in folder\chapter 23\epilcher_quadratics\epilcher_quadratics.java:128: '.class' expected
  selection800=q1.selectionSort(newList800[]);
                                                          ^
\\rabbit2\students\10000\10281\new java folder\eli's turn in folder\chapter 23\epilcher_quadratics\epilcher_quadratics.java:128: ')' expected
  selection800=q1.selectionSort(newList800[]);
                                                          ^
\\rabbit2\students\10000\10281\new java folder\eli's turn in folder\chapter 23\epilcher_quadratics\epilcher_quadratics.java:135: '.class' expected
  insertion800=q1.insertionSort(newList800[]);
                                                          ^
\\rabbit2\students\10000\10281\new java folder\eli's turn in folder\chapter 23\epilcher_quadratics\epilcher_quadratics.java:135: ')' expected
  insertion800=q1.insertionSort(newList800[]);
                                                          ^
24 errors


i know .class expected usually seems to involve botched typecasting, but i don't seem to see any in the part of code in question....anyway any help would be appreciated,
thx
Go to the top of the page
 
+Quote Post
 
Start new topic
Replies (1 - 1)
E-E-R
post May 26 2005, 07:36 PM
Post #2


Advanced Member
***

Group: Members
Posts: 1,364
Joined: 16-March 05
From: The Netherlands
Member No.: 80



If you pass on an array as a parameter, don't put the brackets ( [] ) behind them ;)

CODE
import java.awt.geom.*;
import java.util.*;
import apcslib.*;      
import chn.util.*;

public class epilcher_quadratics
{
public static void main(String[] args)
{
 int[] list100 = new int[100];
 int[] list200 = new int[200];
 int[] list400 = new int[400];
 int[] list800 = new int[800];

 int[] newList100 = new int[100];
 int[] newList200 = new int[200];
 int[] newList400 = new int[400];
 int[] newList800 = new int[800];

 Random die=new Random();
 quadratics q1 = new quadratics();
 general gen1=new general();

 int bubble100, bubble200, bubble400, bubble800, selection100, selection200, selection400, selection800, insertion100, insertion200, insertion400, insertion800;

// ********************************************************************************

 for (int x=0; x<100; x++)
 {
 list100[x]=die.nextInt(200)+1;
 }
 for (int x=0; x<200; x++)
 {
 list200[x]=die.nextInt(400)+1;
 }
 for (int x=0; x<400; x++)
 {
 list400[x]=die.nextInt(800)+1;
 }
 for (int x=0; x<800; x++)
 {
 list800[x]=die.nextInt(1600)+1;
 }

// ********************************************************************************

 for (int x=0; x<100; x++)
 {
 newList100[x]=list100[x];
 }

 bubble100=q1.bubbleSort(newList100);

 for (int x=0; x<100; x++)
 {
 newList100[x]=list100[x];
 }

 selection100=q1.selectionSort(newList100);

 for (int x=0; x<100; x++)
 {
 newList100[x]=list100[x];
 }

 insertion100=q1.insertionSort(newList100);

// ********************************************************************************

 for (int x=0; x<200; x++)
 {
 newList200[x]=list200[x];
 }

 bubble200=q1.bubbleSort(newList200);

 for (int x=0; x<200; x++)
 {
 newList200[x]=list200[x];
 }

 selection200=q1.selectionSort(newList200);

 for (int x=0; x<200; x++)
 {
 newList200[x]=list200[x];
 }

 insertion200=q1.insertionSort(newList200);

// ********************************************************************************

 for (int x=0; x<400; x++)
 {
 newList400[x]=list400[x];
 }

 bubble400=q1.bubbleSort(newList400);

 for (int x=0; x<400; x++)
 {
 newList400[x]=list400[x];
 }

 selection400=q1.selectionSort(newList400);

 for (int x=0; x<400; x++)
 {
 newList400[x]=list400[x];
 }

 insertion400=q1.insertionSort(newList400);

// ********************************************************************************

 for (int x=0; x<800; x++)
 {
 newList800[x]=list800[x];
 }

 bubble800=q1.bubbleSort(newList800);

 for (int x=0; x<800; x++)
 {
 newList800[x]=list800[x];
 }

 selection800=q1.selectionSort(newList800);

 for (int x=0; x<800; x++)
 {
 newList800[x]=list800[x];
 }

 insertion800=q1.insertionSort(newList800);

// ********************************************************************************

System.out.println("# of integers:      100      200      400      800");
System.out.println("--------------------------------------------------");
System.out.println("Bubble Sort:"+Format.right(bubble100, 11));
}
}


--------------------
"Many are persistently in pursuit of the way they have chosen; few in pursuit of the goal"
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

 



RSS Lo-Fi Version Time is now: 7th September 2010 - 12:14 AM