I basically am trying to figure out how to store data into an array by calling a method enterSalary() within another method enterAllEmployees(). This is what the assignment is. I don't understand how to do it.

Your solution must:

Store the salaries in an array (the department may not hire more than 50 students)

Also store the names of the corresponding student workers in an array

Your output should include the list of student workers with their salary and an indication of whether their salary is average, above average or below average

For full credit on this problem you must include the following methods:

howMany( ) – prompt the user for the number of employees

enterAllEmployees() – prompt for name and call enterSalary() for each employee

enterSalary( ) – prompt the user for ONE salary, validate this value to determine if it is between $8 and $15 (per hour)

sum() calculate and return the sum of the items in the salary array

output () call the sum() method, calculate average, build the required output

In this website we won't solve all your problems by pasting a piece of code.

If you have problems with your arrays you could try to use an ArrayList instead of simple arrays. An ArrayList is a linked list (kind of array) which is used to add elements and remove them easily. For example:

ArrayList<Integer> array=new ArrayList<Integer>();
	for(int i=0;i<50;i++)
		array.add(i+20);
	for(int i=0;i<50;i++)
		System.out.println(array.get(i));

In an ArrayList you can store any kind of classes.

You can make something like this:

ArrayList<Salary> salaries=new ArrayList<Salary>();
	for(int i=0;i<50;i++)
		salaries.add(new Salary("45$"));

If you want to know how many elements are in an ArrayList you can call the method .size():

salaries.size();

Here is more information about arraylists.

how to store data into an array

Start with this part and when you understand that, move on to the next part.
What items will go into the array? numbers or Strings or class objects?
Define an array large enough to hold the most data you expect to get.
Define a counter that keeps track of the number of items currently in the list.
You can use the counter as an index to the array.

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.