Enhance the car wash simulation method in Figure 7.8 so that it has the following additional property.
Question:
Enhance the car wash simulation method in Figure 7.8 so that it has the following additional property. There is an additional parameter, which is a maximum length for the queue. When the queue gets as long as this maximum, any customer who arrives will leave without entering the queue (because the customer does not want to wait that long). There should also be one additional simulation result that is printed. In addition to the output shown in Figure 7.8, the method should print the number of simulated customers who left because the queue was too long. Embed the method in a program that allows the user to repeat simulations with different arguments until the user wishes to quit the program.
FIGURE 7.8 Specification and Implementation of the Car Wash Method Specification car WashSimulate public static void carwashSimulate (int washTime, double arrivalProb, int TotalTime) Simulate the running of a car washer for a specified amount of time. Parameters: washTime - the number of seconds required to wash one car arrivalProb - the probability of a customer arriving in any second; for example, 0.1 is 10% totalTime - the total number of seconds for the simulation Precondition: washTime and totalTime are positive; arrivalProb lies in the range 0 to 1. Postcondition: The method has simulated a car wash in which washTime is the number of seconds needed to wash one car, arrivalProb is the probability of a customer arriving in any second, and totalTime is the total number of seconds for the simulation. Before the simulation, the method has written its three parameters to System.out. After the simulation, the method has written two pieces of information to System.out: (1) the number of cars washed, and (2) the average waiting time for customers that had their cars washed. (Customers that are still in the queue are not included in this average.) Throws: I1legalArgumentException Indicates that one of the arguments violates the precondition. Sample Output The carWashSimulate method could be part of an interactive or noninteractive Java program. For example, a noninteractive program might activate carWashSimulate (240, 0.0025, 6000); which can produce this output: Seconds to wash one car: 240 Probability of customer arrival during a second: 0.0025 Total simulation seconds: 6000 Customers served: 13 Average wait: 111.07692307682308 sec The actual output may be different because of variations in the random number generator that is used in the BooleanSource.
Step by Step Answer:
Here is an implementation of the enhanced car wash simulation method in Python import random def car...View the full answer
Students also viewed these Computer science questions
-
You, CA, are the audit senior of Ball Construction Corporation (BC), a small public company. It is September 19, 2013, and the year-end audit fieldwork has just been completed. The audit partner,...
-
Global Touch Corporation (GTC) is one of Canada's largest public companies. GTC provides end users with networking capabilities through its system of copper and coaxial cable lines. GTC operates in...
-
1. A firm consists of 600 acres of land, of which 500 acres will be planted with corn, soybeans, and wheat according to this condition: -At least half of the planted acreage should be in corn - No...
-
Head movement evaluations are important because disabled individuals may be able to operate communications aids using head motion. The paper Constancy of Head Turning Recorded in Healthy Young Humans...
-
Annual values of Canadian exports to Europe and to the areas designated Far East/Oceania (in millions of dollars) were collected in independent random samples: Far East/Oceania: 19,407 16,889 16,688...
-
After a new turbocharger for an automobile engine was developed, the following experimental data were obtained for speed y in miles per hour at two-second time intervals x. (a) Find a least squares...
-
Describe the role of the patient, physician, nurse, and hospital in obtaining informed consent.
-
Dr. Smith learned that one sorority on campus had purchased several Macintosh computers and another sorority had purchased several Windows-based computers. Dr. Smith was interested in whether the...
-
2 If logx2 = 1.2a and logx3 = 1.5a, in terms of a, find the answer to logx 12
-
Mr B aged 52 years, has earned rupees 75,00,000 out of his business. His ex-wife gifted him a car worth rupees 8 lakh. He spent a total of rupees 20 lakh during a family trip. He won a lottery of 16...
-
In Figure 7.3, we presented a program that checks a string to see if the letters in the string read the same forward and backward. The previous exercise performed a similar check using words in place...
-
Give a complete implementation of a priority queue using an array of ordinary queues. For your ordinary queue, use the version from edu.colorado.collections.ArrayQueue in Figure 7.9. FIGURE 7.9...
-
The following table lists the price of a liter of regular gas for 20 nations. Compute the mean and median for these data. The costs are listed in order. This will make the median easy to find. Which...
-
Flint Inc. issued $ 1 , 0 6 0 , 0 0 0 of 1 0 % , 1 0 - year bonds on June 3 0 , 2 0 2 5 , for $ 9 3 8 , 4 1 4 . This price provided a yield of 1 2 % on the bonds. Interest is payable semiannually on...
-
I have a presentation to reflect on the case of Recovering Trust after corportae misconduct at Walls Fargo" on the following question " in what ways was the fraud triangle to blame for the bad...
-
4. (10 marks) Let M2,2 have the standard inner product (u, v) = Tr(uv). Find the cosine of the angle between the vectors Show all working. u = ( ) 02 and V = 3 1 (). 0 2
-
Given the function defined by h (x)=2, find h (-8). Write your answer in exact, simplified form. h(-8)= G
-
b. Solve for the formula 3x + 2y = 11 for y.
-
Browne and Red, both C corporations, formed the BR Partnership on January 1, 2012. Neither Browne nor Red is a personal service corporation, and BR is not a tax shelter. BR's gross receipts were $4.6...
-
Several months have passed and the Managing Partner approved and properly filed the Complaint and properly submitted the Request for Production of Documents that you drafted. In fact, it has been 75...
-
Given an undirected graph G with V vertices and E edges, the sum of the degrees of all vertices is A. E B. 2E C. V D. 2V
-
What are weighted graphs?
-
Consider an undirected random graph of eight vertices. The probability that there is an edge between a pair of vertices is 1/2. What is the expected number of unordered cycles of length three? A. A...
-
1. Mention five key organizational characteristics that the Cll research team identified for organizations with effective quality management systems. provide brief discussion of each and how it...
-
When a metal was exposed to photons at a frequency of 1.46 1015 s1, electrons were emitted with a maximum kinetic energy 3.60 10-19 J. G ? Calculate the work function, , of this metal. J/photon What...
-
No. 101 Debit Cash $ 2,400 Question 2 (10 pts) On November 1, 2024, the account balances of Schilling Equipment Repair were as follows. Accumulated Depreciation-Equipment A Clipboard Font Alignment...
Study smarter with the SolutionInn App