plz do not copy from chegg #include using namespace std; void WaitingTime(int processes[], int n, int bt[],                                int wt[], int at[]) {    int service_time[n];    service_time[0] = 0;    wt[0] = 0;    for (int i = 1; i < n ; i++)    {        service_time[i] = service_time[i-1] + bt[i-1];        wt[i] = service_time[i] - at[i];        if (wt[i] < 0)            wt[i] = 0;    } } // Find turn around time void TurnAroundTime(int processes[], int n, int bt[],                                    int wt[], int tat[]) {    for (int i = 0; i < n ; i++)        tat[i] = bt[i] + wt[i]; } // FInd average waiting and turn-around // times. void AvgTime(int processes[], int n, int bt[], int at[]) {    int wt[n], tat[n];    WaitingTime(processes, n, bt, wt, at);    TurnAroundTime(processes, n, bt, wt, tat);    cout<<"\n\n----------------------OUTPUT---------------------------------->\n\n";    cout << "Processes " << " Burst Time " << " Arrival Time "        << " Turn-Around Time\n";    int total_wt = 0, total_tat = 0;    for (int i = 0 ; i < n ; i++)    {           cout << " p" << i+1 << "\t\t" << bt[i] << "\t\t"            << at[i] << "\t\t" << tat[i] << "\t\t "<< endl;    } cout<<"\n\n Waiting Time and Completion Time for Each Process-->\n\n";    cout << "Processes "<< "Waiting Time"        << " Completion Time \n";    for (int i = 0 ; i < n ; i++)    {        total_wt = total_wt + wt[i];        total_tat = total_tat + tat[i];        int compl_time = tat[i] + at[i];        cout << " p" << i+1 << "\t\t" << wt[i] << "\t\t " << compl_time << endl;    }    cout << "Average waiting time = "        << (float)total_wt / (float)n;    cout << "\nAverage turn around time = "        << (float)total_tat / (float)n<<"\n"; } int main() {    int processes[] = {0,1, 2, 3};    int n = sizeof processes / sizeof processes[0];    int burst_time[] = {5, 3,8, 6};    int arrival_time[] = {0, 1, 2,3};    AvgTime(processes, n, burst_time, arrival_time);    return 0;

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

plz do not copy from chegg

#include<iostream>
using namespace std;

void WaitingTime(int processes[], int n, int bt[],
                               int wt[], int at[])
{
   int service_time[n];
   service_time[0] = 0;
   wt[0] = 0;

   for (int i = 1; i < n ; i++)
   {
       service_time[i] = service_time[i-1] + bt[i-1];


       wt[i] = service_time[i] - at[i];
       if (wt[i] < 0)
           wt[i] = 0;
   }
}

// Find turn around time
void TurnAroundTime(int processes[], int n, int bt[],
                                   int wt[], int tat[])
{
   for (int i = 0; i < n ; i++)
       tat[i] = bt[i] + wt[i];
}

// FInd average waiting and turn-around
// times.
void AvgTime(int processes[], int n, int bt[], int at[])
{
   int wt[n], tat[n];

   WaitingTime(processes, n, bt, wt, at);

   TurnAroundTime(processes, n, bt, wt, tat);

   cout<<"\n\n----------------------OUTPUT---------------------------------->\n\n";

   cout << "Processes " << " Burst Time " << " Arrival Time "
       << " Turn-Around Time\n";
   int total_wt = 0, total_tat = 0;
   for (int i = 0 ; i < n ; i++)
   {
          cout << " p" << i+1 << "\t\t" << bt[i] << "\t\t"
           << at[i] << "\t\t" << tat[i] << "\t\t "<< endl;
   }

cout<<"\n\n Waiting Time and Completion Time for Each Process-->\n\n";
   cout << "Processes "<< "Waiting Time"
       << " Completion Time \n";
   for (int i = 0 ; i < n ; i++)
   {
       total_wt = total_wt + wt[i];
       total_tat = total_tat + tat[i];
       int compl_time = tat[i] + at[i];
       cout << " p" << i+1 << "\t\t" << wt[i] << "\t\t " << compl_time << endl;
   }

   cout << "Average waiting time = "
       << (float)total_wt / (float)n;
   cout << "\nAverage turn around time = "
       << (float)total_tat / (float)n<<"\n";
}

int main()
{

   int processes[] = {0,1, 2, 3};
   int n = sizeof processes / sizeof processes[0];
   int burst_time[] = {5, 3,8, 6};
   int arrival_time[] = {0, 1, 2,3};

   AvgTime(processes, n, burst_time, arrival_time);

   return 0;
}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 5 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY