How many jobs would the Keystone pipe line create?

How to create an array list of 10 jobs using the bubble sort method?

  • So I have to sort the array of jobs using the modified bubble sort. And then print the sorted array in output. But I'm stuck because I'm not sure as to how I can approach that. This is what I have so far for my Driver.Java, but I know I must make corrections in my Jobs.Java code, but am not sure what I have to add or change, well I know I will have to change the bubbleSort method, which is also shown below: [code] public class Driver { public static void main(String[] args) { Job[] jobs = new Job[10]; fillArray(jobs); //after this line the array is filled with Job objects } private static void fillArray(Job[] jobs) { jobs[0] = new Job(); // defaults: salary 30000, name of "Drone", default of 40hrs/week and 1 vacation week jobs[1] = new Job( 59000); // salary given; default name of "Programmer", default of 40hrs/week and 1 vacation week jobs[2] = new Job( "Software Engineer", 65000, 55, 2); jobs[3] = new Job( "Network Analyst", 62000, 65, 3); jobs[4] = new Job( "Network Administrator", 69000, 50, 2); jobs[5] = new Job( "Database Administrator", 78000, 65, 4); jobs[6] = new Job( "Software Tester", 60000, 56, 2); jobs[7] = new Job( "Project Supervisor", 71000, 62, 3); jobs[8] = new Job( "Junior Programmer", 55000, 54, 2); jobs[9] = new Job( "Sales", 70000, 62, 3); } } ///////////////////////////////(Job.Java is a separate file no pasted in the same file as Driver.Java) Job.Java public void bubbleSort (int[] theArray){ int jobs[0], jobs[1]; int size = 0; for (jobs=1; jobs < size; jobs++){//size is the size of the array for (otherJob=0; otherJob< size-job; otherJob++){ if ( theArray[ otherJob] > theArray[ otherJob+1]) { // swap the two array elements swap (theArray, otherJob, otherJob+1); } }//end for (otherJob) }//end for (job) }//end for (bubbleSort) //////////////////////////////////////… two array elements private void swap(int[] theArray, int job, int otherJob ) { // TODO Auto-generated method stub int temp = theArray [job];//store temporarily theArray [job]= otherJob; theArray [otherJob] = temp; } } [/code] When I try running my program I have an error and it has to do with the bubbleSort method, but I'm not sure what I have to chnage there. Please help! Would I have to create 10 separate for/if statements for all the jobs declared in the Driver and would I also have to initialize each one in the Jobs.Java code?? Thanks!

  • Answer:

    you have to swap the jobs themselves not just the integer value. // In main you write like this: swap (jobs[otherJob], jobs[otherJob+1]); //In your function you write like this: private void swap(Job job, Job otherJob ) { // TODO Auto-generated method stub Job temp = new Job(); temp = job;//store temporarily job = otherJob; otherJob = temp; } im just making some crude changes but if you are smart you will get the idea from there.

Nicaragu... at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.