Hi,
I'm trying to do a bubble sort on an employee Id field. After the sort the employee Id's along with the corresponding salaries will be sorted in descending order by Id.
Upon compiling, I get one error message as follows:
E:\EmployeeSort.java:26: bubbleSort(Employee[],int) in EmployeeSort cannot be applied to (int[],int)
bubbleSort(empNum,empNum.length);
Generated from the program that follows:
import javax.swing.*;
public class EmployeeSort
{
public static void main(String[] args)
{
//declare array of 5 employees
Employee[] someEmployee = new Employee [5];
int [] empNum = {3,2,1,5,4};
double [] empSal = {20.15, 15.60, 11.24, 8.34, 25.12};
int i;
for(i=0; i < 5; i++)
e = empNum ;
s = empSal ;
someEmployee = new Employee(e,s);
System.out.println
("Before the sort Employee number " + empNum + " has a salary of " + empSal);
bubbleSort(empNum,empNum.length);
for(i=0; i < empNum.length; i++)
System.out.println
("After the sort Employee number " + empNum + " has a salary of " + empSal);
}
public static void bubbleSort(Employee [] array, int len)
{
int a,b;
Employee temp;
int highSubscript = len -1;
for(a=0; a<highSubscript; ++a)
for(b = 0; b <highSubscript; ++b)
if(array.getEmpNum() < array[b+1].getEmpNum())
{
temp = array;
array = array[b+1];
array[b+1] = temp;
}
}//end of main
}//end of class
Any suggestions on where my problem is?
Thanks,
Tripoli
^
I'm trying to do a bubble sort on an employee Id field. After the sort the employee Id's along with the corresponding salaries will be sorted in descending order by Id.
Upon compiling, I get one error message as follows:
E:\EmployeeSort.java:26: bubbleSort(Employee[],int) in EmployeeSort cannot be applied to (int[],int)
bubbleSort(empNum,empNum.length);
Generated from the program that follows:
import javax.swing.*;
public class EmployeeSort
{
public static void main(String[] args)
{
//declare array of 5 employees
Employee[] someEmployee = new Employee [5];
int [] empNum = {3,2,1,5,4};
double [] empSal = {20.15, 15.60, 11.24, 8.34, 25.12};
int i;
for(i=0; i < 5; i++)
e = empNum ;
s = empSal ;
someEmployee = new Employee(e,s);
System.out.println
("Before the sort Employee number " + empNum + " has a salary of " + empSal);
bubbleSort(empNum,empNum.length);
for(i=0; i < empNum.length; i++)
System.out.println
("After the sort Employee number " + empNum + " has a salary of " + empSal);
}
public static void bubbleSort(Employee [] array, int len)
{
int a,b;
Employee temp;
int highSubscript = len -1;
for(a=0; a<highSubscript; ++a)
for(b = 0; b <highSubscript; ++b)
if(array.getEmpNum() < array[b+1].getEmpNum())
{
temp = array;
array = array[b+1];
array[b+1] = temp;
}
}//end of main
}//end of class
Any suggestions on where my problem is?
Thanks,
Tripoli
^