Write a Payroll class that uses the following arrays as fields:

  • employeeId.
  • hours.
  • payRate.
  • wages.

employeeId.
5658845, 4520125, 7895122, 8777541, 8451277, 1302850, 7580489

I should have two classes:

  1. Asn07Employees
  2. Assignment07

*I am to use arrays and not vectors

Here is some skeleton code that my instructor gave us:

public class Assignment07
{
	public static void main(String []args)
	{
		int ids[] = {5658845, 4520125, 7895122, 8777541, 8451277, 1302850, 7580489 };
		int hours[]={ 12,      15,      7,       16,      -1,      20,      15		};
		float rate[]={6.5f,    12.5f,  1.5f,    10,      16.5f,   20,      32.5f   };
		
		Asn07Employees emps = new Asn07Employees(ids, hours, rate);
		emps.calculateWages();
		System.out.println(emps);
	}
	
	public static void print(String s)
	{
		System.out.println(s);
	}
}
public class Asn07Employees
{
	public int _ids[];
	{
	}	
	public int _hours[];
	{
	}
	public float _rate[];
	{
	} 
	
}

Please help, I don't even know where to start. :[


- Aepexx

Recommended Answers

All 5 Replies

I don't know where to start either because that has to be the poorest written assignment I have ever seen.

And that's just the skeleton code she provided us with to start off from. I still don't know where to start at. :x

you already have several arrays in your application: ids, hours and rate.
so you can see how you create an array.

now, you don't have, from the start, all the values at once to put in the array, but you do know how many elements your array must have, since the number of any of these arrays is the same as the amount of elements you will have.

so, you create an array of Asn07Employees Objects, that can hold to that number of elements.

After that, you create a loop that runs that many time, and you fill the array with the correct elements, being instances of Asn07Employees you create using the information you fetch out of the arrays mentioned earlier

> so, you create an array of Asn07Employees Objects
That would actually make a bit of sense, but the skeleton code provided appears to indicate they are to be handle as a wad of arrays stuffed into a single class. Looks like a bunch of useless nonsense to me.

Just jumping in here, but your Asn07Employees class needs a constructor that will accept the arrays it needs to manipulate. You might also consider using three ArrayList classes to which to add the values of the arrays. Then it's simply a matter of setting up some loops to fill the ArrayList objects, calculate the wages (not sure what the purpose of this method is), and print out the employees.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.