0

I am suppose to be making a program which inputs an employees name(first and last) and their quarterly sales. I am then suppose to output a table of all the employees and the quarterly sales, as well as their total sales. I am suppose to create an array of objects to store each employee as well as their quarterly sales. However i have absolutly no idea how to use an array of objects so i am lost.
right now i have a class called inputGUI which input the names and quarterly sales and a class called Employee which is suppose to do calculations (such as finding the employee with the highest and lowest total sales) with the array after i create it (which i dont know how to do). Im completely lost right now so any help would be very much appreciated.

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by javaAddict
0

Check out "ArrayList", it resizes itself as necessary. If you choose to use it, you would create an "ArrayList" of your class (ex: "Employee").

0

Here is an example with arrays:

Empleoyee emp  = new Empleoyee(); // this is an [B]Empleoyee[/B] 

Empleoyee [] empArray  = new Empleoyee[10]; // this an array

// emp is an Empleoyee
// empArray is an array
// the empArray above is not null

//empArray[0], empArray[1], empArray[2], ... are [B]Empleoyee[/B] but they are null

empArray[0] = new Empleoyee(); // now the empArray[0] is not null

empArray[1] = emp ; // now the empArray[1] is not null

// remember empArray[0] is an Empleoyee
empArray[0].setName("aaaaaa");
System.out.println(empArray[0].getName());

int length = empArray.length; // empArray is an array
System.out.println("Number of employees: "+length);
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.