I have an array contains Employee object.
How do I print every element of the array?
I can only get it to print the last input.
/*This is Employees class
toString accepts lastname, firstname, payrate, workhour, grosspay, tax, netpay, and return a string */
public void display(Employee a[])
{
for (int i=0; i<max; i++)
{
System.out.println(a[i].toString());
}
}
// main
for (int a=0; a<max;a++)
{
list[a]=emps.getinfo(emp);
}
emps.display(list);
//Employee class
// I am assuming there is something wrong with these two methods in my Employee class.
public Employee(Employee e)
{
lastname=e.lastname;
firstname=e.firstname;
}
// Argument will be lastname, firstname, workhour, payrate, grosspay, tax and net.
public String toString()
{
return String.format("format", argument);
}
The following link is the complete code. https://imgur.com/gallery/bTXPSKb
Input
qwe , ewq 5 5
rtw , gtr 7 7
Output
rtw ,gtr 7.00 7.00 49.00 7.35 41.65
rtw ,gtr 7.00 7.00 49.00 7.35 41.65
Expecting
qwe ,ewq 5.00 5.00 25.00 3.75 21.25
rtw ,gtr 7.00 7.00 49.00 7.35 41.65
getInfo.