Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I have done Java program for Round Robin but im not getting expected output. Not sure what is wrong, please help!!! CODE I DID import
I have done Java program for Round Robin but im not getting expected output. Not sure what is wrong, please help!!!
CODE I DID
import java.util.;
class Process
int arrivalTime;
int burstTime;
int priority;
int remainingTime;
int turnaroundTime;
int waitingTime;
String processName;
int completionTime;
ProcessString processName, int arrivalTime, int burstTime, int priority
this.processName processName;
this.arrivalTime arrivalTime;
this.burstTime burstTime;
this.priority priority;
this.remainingTime burstTime;
public class RR
public static void mainString args
Scanner scanner new ScannerSystemin;
System.out.printEnter the number of processes : ;
int n scanner.nextInt;
int arrivalTime new intn;
int burstTime new intn;
int priority new intn;
int turnaroundTime new intn;
int waitingTime new intn;
int totalTurnaroundTime ;
int totalWaitingTime ;
for int i ; i n; i
System.out.printlnEnter details for P i :;
System.out.printArrival Time: ;
arrivalTimei scanner.nextInt;
System.out.printBurst Time: ;
burstTimei scanner.nextInt;
System.out.printPriority: ;
priorityi scanner.nextInt;
System.out.printEnter the time quantum: ;
int quantumTime scanner.nextInt;
int remainingTime new intn;
System.arraycopyburstTime remainingTime, n;
int currentTime ;
boolean finished new booleann;
int finishedCount ;
System.out.println
Gantt Chart:";
while finishedCount n
boolean foundProcess false;
for int i ; i n; i
if finishedi && arrivalTimei currentTime
foundProcess true;
if remainingTimei quantumTime
System.out.print P i ;
currentTime quantumTime;
remainingTimei quantumTime;
else
System.out.print P i ;
currentTime remainingTimei;
remainingTimei;
finishedi true;
finishedCount;
if foundProcess
System.out.print Idle ;
currentTime;
System.out.println
Finished
;
System.out.println PROCESS NAME ARRIVAL TIME BURST TIME
TURNAROUND TIME WAITING TIME ;
for int i ; i n; i
turnaroundTimei currentTime arrivalTimei;
waitingTimei turnaroundTimei burstTimei;
totalTurnaroundTime turnaroundTimei;
totalWaitingTime waitingTimei;
System.out.printf Pd d d
d d
i arrivalTimei burstTimei turnaroundTimei
waitingTimei;
double averageTurnaroundTime double totalTurnaroundTime n;
double averageWaitingTime double totalWaitingTime n;
System.out.println
Total Turnaround Time: totalTurnaroundTime;
System.out.printlnAverage Turnaround Time:
averageTurnaroundTime;
System.out.printlnTotal Waiting Time: totalWaitingTime;
System.out.printlnAverage Waiting Time: averageWaitingTime;
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