Answered step by step
Verified Expert Solution
Question
1 Approved Answer
i have this java code and i need to paraphrase it ( make it look like a new / unique code since i used it
i have this java code and i need to paraphrase it make it look like a newunique code since i used it last year without changing the context and output results and please make sure it works after the changes for example change every variable name and function and any changable thing to make it look unique make each process id in a table for example of something :
import java.util.;
class Process
int id;
int burstTime;
int arrivalTime;
int priority;
int remainingTime;
int waitingTime;
int turnaroundTime;
int responseTime;
boolean isComplete;
boolean isFirstCycle;
public Processint id int arrivalTime, int burstTime, int priority
this.id id;
this.arrivalTime arrivalTime;
this.burstTime burstTime;
this.priority priority;
this.remainingTime burstTime;
this.waitingTime ;
this.turnaroundTime ;
this.responseTime ;
this.isComplete false;
this.isFirstCycle true;
Getter for priority
public int getPriority
return this.priority;
Getter for ID
public int getId
return this.id;
public class PriorityRoundRobinScheduling
public static void mainString args
Scanner scanner new ScannerSystemin;
System.out.printlnEnter quantum time:";
int quantum scanner.nextInt;
List processes new ArrayList;
System.out.printlnEnter process ID arrival time, burst time, and priority terminate with :;
while true
int id scanner.nextInt;
int arrivalTime scanner.nextInt;
int burstTime scanner.nextInt;
int priority scanner.nextInt;
if id && arrivalTime && burstTime && priority
break;
processes.addnew Processid arrivalTime, burstTime, priority;
scanner.close; Close the scanner to avoid resource leaks
Sort processes by arrival time
Collections.sortprocesses Comparator.comparingIntp parrivalTime;
int currentTime ;
int completedProcesses ;
int totalWaitingTime ;
int totalTurnaroundTime ;
int totalResponseTime ;
StringBuilder ganttChart new StringBuilder;
while completedProcesses processes.size
Process current pickNextProcessprocesses currentTime;
if current null
if currentisFirstCycle
current.responseTime currentTime current.arrivalTime;
current.isFirstCycle false;
ganttChart.append pappendcurrentidappend;
int timeSlice Math.minquantum current.remainingTime;
currentTime timeSlice;
current.remainingTime timeSlice;
if currentremainingTime
current.isComplete true;
completedProcesses;
current.turnaroundTime currentTime current.arrivalTime;
current.waitingTime current.turnaroundTime current.burstTime;
totalWaitingTime current.waitingTime;
totalTurnaroundTime current.turnaroundTime;
totalResponseTime current.responseTime;
else
currentTime; Increment the current time if no process is running
ganttChart.append;
System.out.printlnScheduling complete.";
System.out.printlnGantt Chart RR with Priority: ganttChart.toStringtrim;
for Process p : processes
System.out.printlnProcess ID: pid
Turnaround Time: pturnaroundTime
Waiting Time: pwaitingTime
Response Time: presponseTime;
System.out.printlnAverage Turnaround Time: double totalTurnaroundTime processes.size;
System.out.printlnAverage Waiting Time: double totalWaitingTime processes.size;
System.out.printlnAverage Response Time: double totalResponseTime processes.size;
private static Process pickNextProcessList processes, int currentTime
return processes.stream
filterp pisComplete && parrivalTime currentTime
minComparatorcomparingIntProcess::getPrioritythenComparingIntProcess::getId
orElsenull;
Step 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