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;...
-
1. Use the data of Problem 5-14A to prepare Anarel Distributors' multi-step income statement for the year ended May 31, 2014. 2. Corry Anarel, owner of the company, strives to earn a gross margin of...
-
Polystyrene can be made more rigid by copolymerizing styrene with divinylbenzene, What purpose does the divinylbenzene serve? Why is the copolymer more rigid? CH=CH CH=CH
-
If the IRR of Alternative \(A\) is 18 percent, the IRR of Alternative B is 16 percent, and MARR is 12 percent, which of the following is correct? a. Alternative B is preferred over Alternative A. b....
-
Hamilton Construction Company uses the percentage-of-completion method of accounting. In 2012, Hamilton began work under contract #E2-D2, which provided for a contract price of $2,200,000. Other...
-
Criticism of the World Bank is generally on a diverse range of issues but they generally centre around concern about the approaches adopted by the World Bank in formulating their policies, and the...
-
On April 1, 2010, Jose Guadalupe established an interior decorating business, Lodge Designs. During the month, Jose completed the following transactions related to the business: Apr. 1. Jose...
-
Select only 2. Two questions which can be used to address ethical issues impacting organizations and Human Resource Management include: What would my Supervisor say? Does this behavior or result meet...
-
How can a medium sized company handle cash sweeping to be fully automated in the operations.?
-
You are a manufacturer of high-end leather goods. How can process and/or product innovation protect you from counterfeiters that are currently selling products that look almost exactly like yours?...
-
What security safeguards should you consider when you are handling cash?
-
Your next assignment will be an analysis of the place and price decisions of a health services organization as covered in Week 5 and 6. You may use the same organization that was your focus on...
-
Explanation of Contract Law
-
YOUCPA is a regional CPA firm engaged in public audit work of small- and medium-size firms in the Midwest. The YOUCPA firm has their main office in Chicago, Illinois, and regional offices in...
-
9.Consider the reaction 3NO2(g)+H2O=2HNO3(aq)+NO(g) where Delta H=-137 kJ.How many kilojoules are released when 92.3g of NO2 reacts?
-
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...
-
The textbook states that "data is a resource that must be controlled and managed." Explain this statement, and indicate whether you agree of not, and why.
-
Why do conventional files tend be have duplication of data?
-
One of the dealership's legacy stand-alone systems in the preceding exercise is the salesperson work schedule system. This system was developed in the 1980 s on a single \(P C\), using BASE III, to...
Study smarter with the SolutionInn App