In this task, you are supposed to implement a Java program for the scheduling problem of...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
In this task, you are supposed to implement a Java program for the scheduling problem of a famous online order delivery company by using heap-based priority queue. The manager is trying to find how many couriers work in the order delivery part. For each courier in the order delivery, the expense of the company increases; but according to the standards of this company, the average waiting time for all customers should not exceed a given amount of time. So, the manager needs to optimize this number and calls for your help in this task. This company has the data of predict delivery time of customers. Your program should use these data to calculate average waiting times and find the minimum number of couriers needs to meet the average waiting time requirement. You must use your own implementation of heap-based priority queue by taking inspiration from your textbook or web. You are not allowed to use any external library or jar file. The input data are stored in a plain .txt file. The first line of the file shows the number of customers. The subsequent lines contain four integers, each separated by one or more whitespace characters (space or tab). These represent, respectively, the customer id, the registration year of the customer to the company (the company was founded in 1968), arrival time for order (in minutes from a given point, e.g. 12:00 am) and service time (in minutes). Here is the sampleinput1.txt file content: 12 1 1994 1 10 2 1974 1 14 3 2004 1 6 4 2004 1 5 5 1994 4 10 6 1974 7 14 7 1994 9 10 8 1974 11 14 9 2004 13 6 10 2004 14 5 11 1994 15 10 12 1974 17 14 For example, from the sampleinputl.txt file content above, it is seen that there are 12 customers. The first customer with id 1 gives order at minute 1, and his order is delivered in 10 minutes. He has been a customer of the company for 28 years (e.g. 2022 - 1994). The sixth customer with id 6 gives order at minute 7, and his order is delivered in 14 minutes. He has been a customer of the company for 48 years (2022-1974). The seventh customer with id 7 gives order at minute 9, and his order is delivered in 10 minutes. The first and seventh customers have a customer of the company for 28 years, which means that their priorities are the same. You are asked to write a simulation program that reads customer data from sampleinput1.txt file and calculates the minimum number of couriers required for a given maximum average waiting time. The company assigns priority to its customers in order to provide them some special benefits. One of them is that they do not have to wait in the queue for order delivery service. The priority is defined considering the period of time that a customer has been with the company. Long-time customers of the company have higher priority than others. Your implementation must obey the following requirements: ● ● ● ● There may be at most 200 customers in the data file. The customer with the highest priority should be examined first. In case of having two customers with the same highest priority, the customer who has waited longer should be selected first. If more than one couriers is available at a given time; the customer is assigned to the courier with a lower id. When a courier starts giving a service to a customer, the courier should finish his service with this customer even though another customer with a higher priority gives order to company. Once a customer is assigned to a courier, the courier immediately starts delivering order of that customer and is not available during the service time given for that ● customer. After the service of that customer carries out, the courier becomes available immediately. The waiting time of a customer is the duration (difference) between the given order time of the customer and the time he is assigned to a courier. In your implementation, you must use a heap-based priority queue to store customers who are waiting for a courier (i.e., to store customers who have gave order to their order have not been delivered yet). If you do not use such a heap-based priority queue to store these customers, then you will get no points from this task of homework. Firstly, you should read input txt file from the user. Then, you should read the maximum average waiting time. Your program should calculate the minimum number of courier required for meeting this maximum average waiting time. Please check your program with this input file as well as the others that you will create. Please note that we will use other input files when grading your assignments. Sample run is shown as follows, green texts represent user inputs: Enter input filename: sampleinput1.txt Enter the maximum average waiting time: 10 Minimum number of couriers required: 3 Simulation with 3 Couriers: Courier takes customer 2 at minute 1 (wait: 0 mins) Courier 1 takes customer 1 at minute 1 (wait: 0 mins) Courier 2 takes customer 3 at minute 1 (wait: 0 mins) Courier 2 takes customer 6 at minute 7 (wait: 0 mins) Courier 1 takes customer 8 at minute 11 (wait: 0 mins) Courier takes customer 5 at minute 15 (wait: 11 mins) Courier 2 takes customer 12 at minute 21 (wait: 4 mins) Courier takes customer 7 at minute 25 (wait: 16 mins) Courier 1 takes customer 11 at minute 25 (wait: 10 mins) Courier takes customer 4 at minute 35 (wait: 34 mins) Courier 1 takes customer 9 at minute 35 (wait: 22 mins) Courier 2 takes customer 10 at minute 35 (wait: 21 mins) Average waiting time: 9.83333 minutes As a hint, you use the heap data structure to hold customers that are waiting for a courier and to find the customer with the highest priority. Update the heap whenever a new customer gives order or a customer's order is delivered. In order to find the optimum number of couriers needed, repeat the simulation for increasing number of couriers and return the minimum number of waiters that will achieve the maximum average waiting time constraint. Display the simulation for which you find the optimum number of couriers. In this task, you are supposed to implement a Java program for the scheduling problem of a famous online order delivery company by using heap-based priority queue. The manager is trying to find how many couriers work in the order delivery part. For each courier in the order delivery, the expense of the company increases; but according to the standards of this company, the average waiting time for all customers should not exceed a given amount of time. So, the manager needs to optimize this number and calls for your help in this task. This company has the data of predict delivery time of customers. Your program should use these data to calculate average waiting times and find the minimum number of couriers needs to meet the average waiting time requirement. You must use your own implementation of heap-based priority queue by taking inspiration from your textbook or web. You are not allowed to use any external library or jar file. The input data are stored in a plain .txt file. The first line of the file shows the number of customers. The subsequent lines contain four integers, each separated by one or more whitespace characters (space or tab). These represent, respectively, the customer id, the registration year of the customer to the company (the company was founded in 1968), arrival time for order (in minutes from a given point, e.g. 12:00 am) and service time (in minutes). Here is the sampleinput1.txt file content: 12 1 1994 1 10 2 1974 1 14 3 2004 1 6 4 2004 1 5 5 1994 4 10 6 1974 7 14 7 1994 9 10 8 1974 11 14 9 2004 13 6 10 2004 14 5 11 1994 15 10 12 1974 17 14 For example, from the sampleinputl.txt file content above, it is seen that there are 12 customers. The first customer with id 1 gives order at minute 1, and his order is delivered in 10 minutes. He has been a customer of the company for 28 years (e.g. 2022 - 1994). The sixth customer with id 6 gives order at minute 7, and his order is delivered in 14 minutes. He has been a customer of the company for 48 years (2022-1974). The seventh customer with id 7 gives order at minute 9, and his order is delivered in 10 minutes. The first and seventh customers have a customer of the company for 28 years, which means that their priorities are the same. You are asked to write a simulation program that reads customer data from sampleinput1.txt file and calculates the minimum number of couriers required for a given maximum average waiting time. The company assigns priority to its customers in order to provide them some special benefits. One of them is that they do not have to wait in the queue for order delivery service. The priority is defined considering the period of time that a customer has been with the company. Long-time customers of the company have higher priority than others. Your implementation must obey the following requirements: ● ● ● ● There may be at most 200 customers in the data file. The customer with the highest priority should be examined first. In case of having two customers with the same highest priority, the customer who has waited longer should be selected first. If more than one couriers is available at a given time; the customer is assigned to the courier with a lower id. When a courier starts giving a service to a customer, the courier should finish his service with this customer even though another customer with a higher priority gives order to company. Once a customer is assigned to a courier, the courier immediately starts delivering order of that customer and is not available during the service time given for that ● customer. After the service of that customer carries out, the courier becomes available immediately. The waiting time of a customer is the duration (difference) between the given order time of the customer and the time he is assigned to a courier. In your implementation, you must use a heap-based priority queue to store customers who are waiting for a courier (i.e., to store customers who have gave order to their order have not been delivered yet). If you do not use such a heap-based priority queue to store these customers, then you will get no points from this task of homework. Firstly, you should read input txt file from the user. Then, you should read the maximum average waiting time. Your program should calculate the minimum number of courier required for meeting this maximum average waiting time. Please check your program with this input file as well as the others that you will create. Please note that we will use other input files when grading your assignments. Sample run is shown as follows, green texts represent user inputs: Enter input filename: sampleinput1.txt Enter the maximum average waiting time: 10 Minimum number of couriers required: 3 Simulation with 3 Couriers: Courier takes customer 2 at minute 1 (wait: 0 mins) Courier 1 takes customer 1 at minute 1 (wait: 0 mins) Courier 2 takes customer 3 at minute 1 (wait: 0 mins) Courier 2 takes customer 6 at minute 7 (wait: 0 mins) Courier 1 takes customer 8 at minute 11 (wait: 0 mins) Courier takes customer 5 at minute 15 (wait: 11 mins) Courier 2 takes customer 12 at minute 21 (wait: 4 mins) Courier takes customer 7 at minute 25 (wait: 16 mins) Courier 1 takes customer 11 at minute 25 (wait: 10 mins) Courier takes customer 4 at minute 35 (wait: 34 mins) Courier 1 takes customer 9 at minute 35 (wait: 22 mins) Courier 2 takes customer 10 at minute 35 (wait: 21 mins) Average waiting time: 9.83333 minutes As a hint, you use the heap data structure to hold customers that are waiting for a courier and to find the customer with the highest priority. Update the heap whenever a new customer gives order or a customer's order is delivered. In order to find the optimum number of couriers needed, repeat the simulation for increasing number of couriers and return the minimum number of waiters that will achieve the maximum average waiting time constraint. Display the simulation for which you find the optimum number of couriers.
Expert Answer:
Answer rating: 100% (QA)
To solve this problem we can follow these steps 1 Read the input data from the file 2 Implement a heapbased priority queue to store customers waiting for a courier 3 Simulate the order delivery proces... View the full answer
Related Book For
Ethics in Accounting A Decision Making Approach
ISBN: 978-1118928332
1st edition
Authors: Gordon Klein
Posted Date:
Students also viewed these programming questions
-
In this project, you are supposed to implement several programs which will search wordsprovided by the user in a number of input files and will output the matching lines. The programs will be named...
-
Read the case study "Southwest Airlines," found in Part 2 of your textbook. Review the "Guide to Case Analysis" found on pp. CA1 - CA11 of your textbook. (This guide follows the last case in the...
-
If the Stock Dividends < 25%, recorded at fair market value. If the Stock Dividends > 25%, recorded at book value. Example1: Velvet Company has 5,000 shares issued and outstanding. Par value is $1;...
-
Fred's Catering Ltd. had the following selected transactions during May 2014: May 1 Received $800 in advance for a banquet to be served later 5 Paid electricity expenses, $700 9 Received cash for the...
-
Discuss how the new classical economists (hint, island) addressed the fact that money is leading and pro-cyclical. Be extremely specific in the model that was developed (tell a story) and relate the...
-
Place the corresponding letter of the definition next to the term. a. An organization that stands as a separate economic unit must not have its financial affairs confused with that of other entities....
-
A stream of air enters a 7.50-cm ID pipe at a velocity of 60.0 m/s at 27C and 1.80 bar (gauge). At a point downstream, the air flows through a 5.00 cm ID pipe at 60C and 1.53bar (gauge). What is the...
-
A blacksmith with 80 kg. of steel and 120 kg. Aluminum wants to make touring and mountain bikes that he wants to sell each at $5,000 and $7,000 pesos respectively to get the maximum profit. For the...
-
Determine the zero-force members in the Pratt roof truss. Explain your answers using appropriate joint free-body diagrams. A B 300 N C 400 N D L K J E F I H 12 m, 6 @ 2 m- 3 m
-
Billings Company has developed the following budgeted income statement: Sales Revenue (2,300 units $14 sales price) $32,200 Total Variable Expenses (2,300 $6 per unit) (13,800) Contribution Margin...
-
What role do social institutions play in shaping individual and collective identities, and how do these identities intersect with race, gender, sexuality, and other aspects of social diversity to...
-
Suppose the principal, the shareholders, is risk neutral, caring only about the expected amount of money he or she receives, and the agent (the CEO) is risk averse and also averse to providing more...
-
Future of Health Care Management What would your first five actions be if you were appointed to serve as a project manager? Explain why.
-
If -85] A = 5 7 -T and Q(x) = x Ax, then Q() = Q(2) =
-
Cash received from long-term notes payable Purchase of investments Cash dividends paid $ 20,000 5,000 16,000 8,000 Interest paid Compute cash flows from financing activities using the above company...
-
needed solution now please through half hr help me Negative voltage regulation can be expected in case of Slow speed alternator High-speed alternator Lagging power factor load Leading power factor...
-
How has the globalization of firms affected the diversity of their employees? Why has increased diversity put an additional burden on accounting systems?
-
A CFO and CEO potentially are subject to huge financial penalties if they incorrectly certify to the SEC that their company's internal controls function properly, and they do not. They similarly are...
-
To treat chickens more humanely, Californians voted by popular referendum to enact a law requiring minimum cage sizes for egg-laying chickens. Other large egg-producing states, such as Iowa,...
-
To entice a new Chief Operating Officer to leave her current job, a publicly traded stock brokerage firm wants to extend credit to her in the following situations: The company will lend $100,000 to...
-
Let a be the number such that the area to the right of z = a is 0.21. Without using a table or technology, find the area between z = a and z = a.
-
Your medical terminology instructor listed the following grades for the class out of a 75-point test: 34, 36, 41 , 43, 44,49,50, 55,57, 60,64, 66, 67,67, 67,68,68,69, 70, 73 a. Find the 90th...
-
From the following list of number of discharges each day in September, compute the mean, median, mode, and range. Round the mean and median to one decimal point. University Hospital Number of...
Study smarter with the SolutionInn App