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...
-
The athlete shown pulls a 70.0 kg training sled (uk=0.650) at a constant velocity. Given that the angle between the connecting rope and the ground is 40 degrees, determine the force, F, he is...
-
the ways graphs can lie, and how to spot such lies
-
Explain the competitive process when a firm earns a positive economic profit.
-
Jeremy Corporation estimated manufacturing overhead costs for the year to be $550,000. Jeremy also estimated 7000 machine hours and 2000 direct labor hours for the year. It bases the predetermined...
-
National news on television features commercials describing pharmaceutical drugs that treat ailments that plague older people. Apparently, the major networks believe that older people tend to watch...
-
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...
-
Use the given molar solubilities in pure water to calculate K sp for each compound. a. BaCrO 4 ; molar solubility = 1.08 * 10 -5 M b. Ag 2 SO 3 ; molar solubility = 1.55 * 10 -5 M c. Pd(SCN) 2 ;...
-
Service provides commercial and industrial appraisals and feasibility studies. On January 1 , the assets and liabilities of the business were the following: Cash, \(\$ 8,700\); Accounts Receivable,...
-
Sketch the mapping of the value chain for: a A consulting firm b An airline c A trading firm d A corporate and investment bank e An internet-based platform (e.g. Airbnb, Netflix)?
-
Red River Banking Company has ten automatic i) AND teller machines (ATMs) spread throughout the city maintained by the ATM Department. You have been assigned the task of determining the cost of...
-
Super Day Spa provided \(\$ 120,000\) of services during 2012. All customers paid for the services with credit cards. Super submitted the credit card receipts to the credit card company immediately....
-
The following data represent the height of 26 statistics students as measured in inches: a. Create a frequency table for these data. b. Create a histogram for these data with an interval width of 1...
-
Suppose a ball is drawn from a bag containing 9 red balls numbered 1 through 9 and 3 white balls numbered 10 through 12. Two possible sample spaces for this event are S 1 = {1, 2, 3, . . . . . . 12}...
-
31. What is the income that can be received over 15 years from $500,000 earning 6% annually? 32. What is the semiannual payment required to retire $50,000 in debt over 5 years at 8% compounded...
-
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...
-
Saly paid $52,000 a year paid on a weekly basis. last pay she had $250 withheld in Income Tax, $48.97 for CPP and $15.80 for EI. an additional $and 25.00 in tax are deducted each pay. She allowed to...
-
Required information [The following information applies to the questions displayed below.] Dain's Diamond Bit Drilling purchased the following assets this year. Asset Drill bits (5-year) Drill bits...
-
Which of the following partnership items are not included in the self-employment income calculation? Ordinary income. Section 179 expense. Guaranteed payments. Gain on the sale of partnership...
Study smarter with the SolutionInn App