I need help writing the second function. I am not getting the correct output when I write
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
calc_boarded (boarding, departing, current) - Calculates and returns the new number of items in a queue based on the number of items arriving at the queue, the number of items departing the queue, and the number of items that are already in the queue. Note that this is a general count-based implementation of the FIFO queue described above. Note that this function does not output (print) the computed value! This only performs the essential computation common to any simple count-based queue, nothing about bus lines. Here are some example return values calculated by the calc_boarded function: calc_boarded (20, 10, 15) returns 25 calc_boarded (20, 10, 5) returns 20 # Note, only 5 can exit despite the exit rate calc_boarded (5, 10, 15) returns 10 run_sim (stops, board_rate, exit_rate, starting passengers) - Executes the simulation, calculating and outputting the number of passengers riding, boarding, and exiting the bus line for each stop. The simulation stops after outputting the line that represents the final destination. This function should implement the design you documented in your sim_design.pdf (above). Here is an example output generated by run_sim (10, 15, 10, 5): 1 5 15 5 2 15 10 3 10 4 5 69 7 8 9 20 25 30 35 40 45 50 15 15 15 15 15 15 15 15 99 10 10 10 10 10 10 10 55 55 Note that you need to output the data in the tabular format as shown in the example output above. Consider using the string format method we've learned to generate the formatted output. calc_boarded (boarding, departing, current) - Calculates and returns the new number of items in a queue based on the number of items arriving at the queue, the number of items departing the queue, and the number of items that are already in the queue. Note that this is a general count-based implementation of the FIFO queue described above. Note that this function does not output (print) the computed value! This only performs the essential computation common to any simple count-based queue, nothing about bus lines. Here are some example return values calculated by the calc_boarded function: calc_boarded (20, 10, 15) returns 25 calc_boarded (20, 10, 5) returns 20 # Note, only 5 can exit despite the exit rate calc_boarded (5, 10, 15) returns 10 run_sim (stops, board_rate, exit_rate, starting passengers) - Executes the simulation, calculating and outputting the number of passengers riding, boarding, and exiting the bus line for each stop. The simulation stops after outputting the line that represents the final destination. This function should implement the design you documented in your sim_design.pdf (above). Here is an example output generated by run_sim (10, 15, 10, 5): 1 5 15 5 2 15 10 3 10 4 5 69 7 8 9 20 25 30 35 40 45 50 15 15 15 15 15 15 15 15 99 10 10 10 10 10 10 10 55 55 Note that you need to output the data in the tabular format as shown in the example output above. Consider using the string format method we've learned to generate the formatted output.
Expert Answer:
Related Book For
Financial Accounting and Reporting a Global Perspective
ISBN: 978-1408076866
4th edition
Authors: Michel Lebas, Herve Stolowy, Yuan Ding
Posted Date:
Students also viewed these programming questions
-
List three specific parts of the Case Guide, Objectives and Strategy Section (See below) that you had the most difficulty understanding. Describe your current understanding of these parts. Provide...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
The production of paper involves a pulping step to break down wood chips into cellulose and lignin. In the Kraft process, an aqueous, pulping-feed solution, known as white liquor, is used that...
-
When the play button is pressed, a CD accelerates uniformly from rest to 450 rev/min in 3.0 revolutions. If the CD has a radius of 6.0 cm and a mass of 17 g, what is the torque exerted on it?
-
Assume the United States and Japan are unable to resolve a trade war over trade in automobiles and auto parts. Acting unilaterally, the United States imposes punishingly high tariffs of 100 percent...
-
Two canals join to form a larger canal as shown in Video V10.6 and Fig. P10.62. Each of the three rectangular canals is lined with the same material and has the same bottom slope. The water depth in...
-
Dewitt Industries has adopted the following production budget for the first 4 months of 2012. Each unit requires 3 pounds of raw materials costing $2 per pound. On December 31, 2011, the ending raw...
-
4. Evaluate the following limits, if they exist. If a limit does not exist, state DNE. For these limits, recall that lim tan x a. lim X-0 x sin x COS X-1 = 1 and lim = 0. X-0 x X40X b. lim sin(x-1)...
-
The Kennedy Company is closely held and, therefore, cannot generate reliable inputs with which to use the CAPM method for estimating a company's cost of internal equity. Kennedy's bonds yield 11.52%,...
-
Lynne needs to borrow $8500 for cosmetic surgery. She obtains a loan from her grandmother for 54 months at a simple interest rate of 7.6%. What is the loans future value?
-
A new bond issue has an annual yield of 5.6%. The bond pays coupons twice a year . What is the effective annual yield (EAY) on the investment?
-
You have been searching the title of a particular parcel of property as part of the preclosing procedures and notice that a deed recorded in 1977 indicates in the encumbrance clause that the property...
-
Luciana passed away at the age of 75 with $50,000 remaining in her RRIF. She named her grandson Sebastian, who is 16 as beneficiary. Sebastian's family is interested in helping him save on the taxes...
-
A client has completed a loan application. All documents are in order and she meets the lender's criteria to be approved for the loan. However, something just does not feel right to you. You feel...
-
Notes on similarities, differences, and patterns you see across all companies, your ideas on potential explanations for these, and your recommendation on the best company to invest in. Compute the...
-
In Exercises 15 through 30, find the derivative dy/dx. In some of these problems, you may need to use implicit differentiation or logarithmic differentiation. y ex + et -2x 1 + e
-
The common-size income statements of Procter & Gamble have been prepared for the years 20072011 (see Table 16.3 in this chapter). Required 1. What financial performance intermediate balance does not...
-
Multiple Choice Questions Select the right answer (only one possible answers unless otherwise stated). 1 Which of the following does IASB stand for? (a) Internationally Accepted Standards Board (b)...
-
ArcelorMittal is a global steel producer headquartered in Luxembourg. The statement of financial position and statement of operations for the years 2006 to 2011 (source: annual reports 20062011),...
-
In Figure 31. 28, which of the three bulbs \(F, G\), and \(H\) light up? Data from Figure 31. 28 (e) H
-
In Figure 31. 27, bulb E is brighter than bulb D. Which bulb has \((a)\) the greater potential difference across it, \((b)\) more current in it, and \((c)\) more resistance? Data from Figure 31. 27 D...
-
A thick resistor and a thin resistor of the same length and material are connected in series, as shown in Figure 31. 29. Which resistor has \((a)\) the greater potential difference across it and...
Study smarter with the SolutionInn App