public class CustomerArrival { int arrivalTime; int startServiceTime; int endServiceTime; int waitingTime; } CustomerArr
Posted: Fri Jul 08, 2022 6:35 am
SetB - Question2(2022) followed by the total and average waiting time. Sample Input-Output Input 2 7 8 24 25 28 0 Output 2#2#9#0 7#9#16#2 8#16#23#8 24#24#31#0 25#31#38#6 28#38#45#10 Total waiting time: 26 unit Average waiting time: 4.33 unit
SetB - Question2(2022) Proposed Algorithm 1. Define a CustomersArrival class that has four attributes; 2. 3. 28#38#45#10 Total waiting time: 26 unit Average waiting time: 4.33 unit arrival Time, startServiceTime, endServiceTime and waiting Time. Create a Queue of CustomerArrival. Based on standard input, for non-zero arrival time: Set the arrival Time Calculate the startServiceTime. o For the first customer, • startServiceTime = arrival Time. o For the others, • startServiceTime = endServiceTime of previous customer or his arrival Time, whichever the earliest. Calculate the endServiceTime: o endServiceTime = startServiceTime + task completion period Calculate the waiting Time: o waiting Time = startServiceTime - arrival Time 4. Calculate average waiting Time; all waiting times divide by the number of customers 5. Display all information based on the following format: <arrivalTime>#<startServiceTime>#<endServiceTime>#<waitingTime> 6. Display total and average waiting time + Grading Criteria