Click here to Skip to main content
15,920,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
String[] list;int[] listStu = new int[100];
System.out.println("| Rank | #Employee | Job Name - Number |");
for (int i = 0; i < list.length - 1; i += 2) {
    for (n = 1; n < listS.length; n++) {
        }
            System.out.println("|\t" + j[n]++ + "\t|\t " + listS[i] + " | " + list[i] + "-" +
                    list[i+1]+"\t|");
                        }


What I have tried:

j[n]++ is the Rank

listS[i] is the number of employees for the Job

list[i] is the job

and list[i + 1] is the job number

So basically what I need to do is rank the jobs with the most employees as the highest and the same rank can be given to the jobs with the same number of employees. I tried using another for-loop but it wasn't working how I wanted it to work, sometimes I had the same rank as the #Employees or it would be 0 for the ranks and the employee could go up.
Example 
Rank  #Employees Job name - Number
 1        3        Engr   - 444
 2        2        doct   - 555
 2        2        plom   - 777
 3        1        trck   - 888
Posted
Updated 20-Mar-23 3:59am
Comments
CHill60 20-Mar-23 9:53am    
Share the code that you used to try to determine the ranks

1 solution

Start by throwing away the current data store: create a class which contains individual properties for the Rank, Employee count, Job name, and Job number.

Then add those to a single collection and you can order element of that (or query it) as necessary without having to faff about with multiple arrays.

You can even have the class print itself to make your code a lot easier to read.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900