QUESTION DESCRIPTION
Bogar a student of Tamil Siddhar College On his birthday took his n Friends (F1, F2, F3. Fn) to SRM Restaurant for a treat. The waiter noted the order of F1, F2, F3. Fn as O1, O2, O3. On respectively. Assuming the waiter services the groups that comes on first to his table.
Print the waiting time, time at which chef starts to prepare the order (Preparation start time) (service time) and time in which the order completes (turnaround time) for each one of them. Print the average waiting and average turnaround time.
Assume F1 gets the menu first and orders first then F2 and so on Therefore the time at which the order is given to the waiter (Arrival time) changes for each friend.
Input: The first line contains the Number of friend/s. The next n line contains the Friend name, order give time(Burst Time) and time taken by chef to cook that order for F1, F2, F3. Fn. (Arrival Time)
Output: - The first n lines should print input values, waiting time and Time in which the order completes (Turn Around time) for each friend in each line. Print average waiting and average turnaround time in next two lines respectively.
Bogar a student of Tamil Siddhar College On his birthday took his n Friends (F1, F2, F3. Fn) to SRM Restaurant for a treat. The waiter noted the order of F1, F2, F3. Fn as O1, O2, O3. On respectively. Assuming the waiter services the groups that comes on first to his table.
Print the waiting time, time at which chef starts to prepare the order (Preparation start time) (service time) and time in which the order completes (turnaround time) for each one of them. Print the average waiting and average turnaround time.
Assume F1 gets the menu first and orders first then F2 and so on Therefore the time at which the order is given to the waiter (Arrival time) changes for each friend.
Input: The first line contains the Number of friend/s. The next n line contains the Friend name, order give time(Burst Time) and time taken by chef to cook that order for F1, F2, F3. Fn. (Arrival Time)
Output: - The first n lines should print input values, waiting time and Time in which the order completes (Turn Around time) for each friend in each line. Print average waiting and average turnaround time in next two lines respectively.
TEST CASE 1
INPUT
INPUT
4
eLabTeam
eThinkTeam
eCurriculaTeam
eVerifyTeam
3 6 4 2
0 0 0 0
OUTPUTWaiting Time
Time Taken for eLabTeam=0
Time Taken for eThinkTeam=3
Time Taken for eCurriculaTeam=9
Time Taken for eVerifyTeam=13
Average Waiting Time=6.250000
TurnAround Time
Time Taken for eLabTeam=3
Time Taken for eThinkTeam=9
Time Taken for eCurriculaTeam=13
Time Taken for eVerifyTeam=15
Average TurnAround Time=10.000000
TEST CASE 2
INPUT
INPUT
5
eLabTeam
eThinkTeam
eCurriculaTeam
eVerifyTeam
eResearchTeam
3 6 4 2 9
0 0 0 0 0
OUTPUTWaiting Time
Time Taken for eLabTeam=0
Time Taken for eThinkTeam=3
Time Taken for eCurriculaTeam=9
Time Taken for eVerifyTeam=13
Time Taken for eResearchTeam=15
Average Waiting Time=8.000000
TurnAround Time
Time Taken for eLabTeam=3
Time Taken for eThinkTeam=9
Time Taken for eCurriculaTeam=13
Time Taken for eVerifyTeam=15
Time Taken for eResearchTeam=24
Average TurnAround Time=12.800000
Code :
#include <iostream>
#include<iomanip>
using namespace std;
int main()
{
int size,sum=0,sum1=0;
float res,res1;
cin>>size;
string ar[size];
for(int i=0;i<size;i++)
{
cin>>ar[i];
}
int burst[size],wait[size],burst1[size];
for(int i=0;i<size;i++)
{
cin>>burst[i];
burst1[i]=burst[i];
}
for(int i=0;i<size;i++)
{
cin>>wait[i];
}
cout<<"Waiting Time\n";
for(int i=0;i<size;i++)
{
if(i==0)
{
cout<<"Time Taken for "<<ar[i]<<"=0";
}
else
{
cout<<"\nTime Taken for "<<ar[i]<<"="<<burst[i-1];
burst[i]+=burst[i-1];
sum=sum+burst[i-1];
}
}
res=(float)sum/size;
cout<<fixed;
cout<<"\nAverage Waiting Time="<<res;
cout<<"\nTurnAround Time";
for(int i=0;i<size;i++)
{
cout<<"\nTime Taken for "<<ar[i]<<"="<<burst1[i];
burst1[i+1]=burst[i]+burst1[i+1];
sum1=sum1+burst1[i];
}
res1=(float)sum1/size;
cout<<fixed;
cout<<"\nAverage TurnAround Time="<<res1;
return 0;
}