Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Can someone code this in Java. I need a similar output as shown in the pic. Exercise Use the class PriorityQueue to build a processor
Can someone code this in Java. I need a similar output as shown in the pic.
Exercise Use the class PriorityQueue to build a processor scheduler that receives multiple processes with variant priorities. The processor will ask the processor scheduler about the next process to serve. The scheduler should remove the process that has the highest priority. Once the processor is done, the processor asks the scheduler again about the next process to serve and so on. The program ends when all processes are served. For the sake of this assignment we will work on serving 10 processes. You project should contain only 2 classes: Class: Process This class contains 2 data members: ID sequential number (first object id-1, second object id-2,, .etc) Priority- random number from 1 to 100 (higher number higher priority) Hint 1: You can implement an object counter using a static data member Class: P This class has the main method that will call two functions 1. GenerateProcesses: This function will create 10 processes. Each process will be chedulerTest assigned a priority number that is a random number from 1 to 100. Each process object is added to the PriorityQueue. The information about the processes objects should be printed out as shown in the following Figure. Hint 2: To generate a random number in Java you can use the Math.Random class. EMile aXlk: https://www.geekstorgeeks.org/generating-random-numbers-in-javal 2. ServerProcesses: This function represents the processor that serves the processes in the Priority Queue. The queue will serve the process that has the highest priority. The order of serving the processes should also be printed out as shown in the following FigureStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started