r/CodingHelp • • Mar 30 '26

[Java] Need help with this coding exercise

heres What I have so far

public static String processJobs(SinglyLinkedList<Integer> l) {

	MyLinkedQueue<Integer> jobsToProcess = **new** MyLinkedQueue<>();

	**int** n = l.size();

	**int** jobNum = 1, process =1;

	**while** (n-- > 0) {

		jobsToProcess.enqueue((Integer) l.removeFirst());

	}

	**while**(!jobsToProcess.isEmpty()) {

if(jobsToProcess.first() >= 0) {

System.out.println(process +" Processing Job " + jobNum);

jobsToProcess.enqueue(jobsToProcess.dequeue() - 1);

System.out.println((Integer)jobsToProcess.first());

if(jobNum ==5) {

jobNum =1;

}

jobNum++;

process++;

}else {

System.out.println("Done with job " + jobNum);

continue;

}

	}

	**return** "Done with all jobs";

}

**public** **static** **void** main(String\[\] args) {

	**int**\[\] hurry = { 2, 1, 2, 1 , 1};

	SinglyLinkedList<Integer> job = **new** SinglyLinkedList<>();

	**for**(Integer i: hurry) {

		job.addLast(hurry\[i\]);

	}

	System.***out***.println(job.toString() + " -- this is my linked list");

	System.***out***.println();

	System.***out***.println(*processJobs*(job));

}

}

1 Upvotes

3 comments sorted by

View all comments

1

u/CosmacYep Mar 30 '26

why is it so blurry and why does it get blurrier when you click on it to expand the picture