Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help translating C code to Java This is C program representing the Round Robin algorithm in Operating System. I need help to translate the

Need help translating C code to Java

This is C program representing the Round Robin algorithm in Operating System. I need help to translate the following C into Java

C program: #include int main() { int i,j,n,time,remain,flag=0,ts; int sum_wait=0,sum_turnaround=0,at[10],bt[10],rt[10]; printf("Enter no of Processes : "); scanf("%d",&n); remain=n; for(i=0;i0) { time+=rt[i]; rt[i]=0; flag=1; } else if(rt[i]>0) { rt[i]-=ts; time+=ts; } if(rt[i]==0 && flag==1) { remain--; printf("P[%d]\t|\t%d\t|\t%d ",i+1,time-at[i],time-at[i]-bt[i]); sum_wait+=time-at[i]-bt[i]; sum_turnaround+=time-at[i]; flag=0; } if(i==n-1) i=0; else if(at[i+1]<=time) i++; else i=0; } printf(" Avg sum_wait = %f ",sum_wait*1.0/n); printf("Avg sum_turnaround = %f",sum_turnaround*1.0/n); return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions