Create a while loop to keep the simulation running

Assignment Help Other Engineering
Reference no: EM131879460

For your assignment, turn in two m-files, a function and a script.

The Krusty Krab is open daily and features 3 items on the menu: Krabby Patties, Kelp Rings, and Coral Bits. They each cost $1.25, $1.50, and $1.00 respectively.

In this simulation we will assume there are an unlimited number of potential customers who want to order. The Krusty Krab can only close after all items have been sold.

Every customer has a 1 in 3 chance of ordering each item from the menu while all 3 items are in stock. This means that a customer could order 0 items, 1 item, 2 items, or all 3 items (The probability of ordering all three is (1/3)*(1/3)*(1/3) = 1/27).

If an item runs out of stock then the probability of the other 2 items gets raised to a 1 in 2 chance of ordering each item. If there is only 1 item left, then the probability of that item gets raised to a 3 in 4 chance of ordering it.

YOUR FUNCTION -

Create a function with three scalar inputs: number of Krabby Patties (P), number of Kelp Rings(R), and number of Coral Bits(B), and two outputs: total revenue "Rev" a scalar, and inventory "Inv" a matrix.

1. Initialize a 1x3 vector of zeros called Orders. Each row represents a customer. The first column represents Krabby Patties, second is Kelp Rings, third is Coral Bits. The columns should be filled with 0s and 1s. 1s represent if the item was bought and 0s represent if the item was not bought.

2. Initialize a 1x1 vector called CustRev and store the revenue generated from each customer in it.

3. Initialize your Inv vector using the three inputs, P, R, and B. Inv represents the amount of inventory of each of the three items, when a customer is done ordering.

4. Create a while loop to keep the simulation running until all items have been sold. I'd recommend creating a scalar that represents the total number of items remaining, and updating it each iteration.

a. Decide if the customer bought each item with the probabilities listed above and mark the column in Orders with a 0 or 1. Use an "if" statement to adjust the probabilities for each item in an order depending on how many items are left in stock.

b. Update Orders and Inv depending on what items the customer may have bought.

c. In the CustRev vector, calculate the cost of the order and add in tip. 7% tip if they bought 1 item, 10% if they bought 2 items, and 15% if they bought all 3 items.

d. At the end of each iteration in the loop, if the total is still greater than 0, add another row of zeros to Orders, a zero to the end of the CustRev vector, and a new row to the end of Inv that is the current inventory. Basically, these variables grow each iteration.

5. Calculate the total revenue generated from the day and store the value as the output (Rev).

YOUR SCRIPT

Create a script that will compare the total revenues from multiple days of service.

1. Initialize a 1x7 vector of zeros called RevWeek.

2. Use a for loop to call the function 7 separate times, with P=300, R=300, and B=300 as the initial values (inputs) each time. Store the revenue outputs in the RevWeek vector.

3. Each time through the loop, plot each column of the Inventory output on one plot with three separate subplots, using subplot(3,1,...). So on one subplot, you'll have 7 lines representing the value of P throughout the day, and then 7 separate lines for R, and then for B.

4. After the loop is done, plot RevWeek using appropriate titles and axes labels.

5. Create a 1x30 vector of zeros called "RevMonth".

6. Use a for loop to call the function 30 separate times with variables, P=300, R=150, B=150. Store the results in the RevMonth vector.

7. For each iteration, keep track of the number of customers it takes to sell out and store this in a vector too, called "Customers"

8. Create identical plots as you did for the weekly revenue, i.e. Inv and RevMonth. Use a comment in your code to discuss the results in a few sentences.

9. Plot the RevMonth and Customers results on two separate histograms using "hist"

Reference no: EM131879460

Questions Cloud

How do childhood experiences influence personality : Use the library databases to find 2 scholarly articles that are relevant to your chosen research question.
Statements about the dow jones industrial average : Which of the following statements about the Dow Jones Industrial Average (DJIA) is incorrect?
When company analyzes its short term financing needs : When a company analyzes its short term financing needs, its typically examines cash flow at:
What are your initial thoughts : Read your peer's essay from beginning to end just to let its ideas wash over you. What are your initial thoughts? Did peer satisfy requirements of assignment?
Create a while loop to keep the simulation running : Create a function with three scalar inputs: number of Krabby Patties (P), number of Kelp Rings(R), and number of Coral Bits(B).
More expensive is the european basket : Regarding Q1, how much cheaper/more expensive is the European basket (in dollars) than the dollar cost of the U.S. basket?
What is most surprising about what the writer says : What line appears most important to the meaning of the essay - What does the theme, lesson, or insight seem to be - Does the writer have transitional
What was the main point of the show : What did you gain from watching this show? What did you like about it? What did you find lacking or would have liked to see that was missing?
Calculate the molar mass of the compound : The osmotic pressure of the resulting solution was 4.86 atm. Calculate the molar mass of the compound.

Reviews

Write a Review

Other Engineering Questions & Answers

  Characterization technology for nanomaterials

Calculate the reciprocal lattice of the body-centred cubic and Show that the reciprocal of the face-centred cubic (fcc) structure is itself a bcc structure.

  Calculate the gasoline savings

How much gasoline do vehicles with the following fuel efficiencies consume in one year? Calculate the gasoline savings, in gallons per year, created by the following two options. Show all your work, and draw boxes around your answers.

  Design and modelling of adsorption chromatography

Design and modelling of adsorption chromatography based on isotherm data

  Application of mechatronics engineering

Write an essay on Application of Mechatronics Engineering

  Growth chracteristics of the organism

To examine the relationship between fermenter design and operating conditions, oxygen transfer capability and microbial growth.

  Block diagram, system performance and responses

Questions based on Block Diagram, System Performance and Responses.

  Explain the difference in a technical performance measure

good understanding of Mil-Std-499 and Mil-Std-499A

  Electrode impedances

How did this procedure affect the signal observed from the electrode and the electrode impedances?

  Write a report on environmental companies

Write a report on environmental companies

  Scanning electron microscopy

Prepare a schematic diagram below of the major parts of the SEM

  Design a pumping and piping system

creating the pumping and piping system to supply cool water to the condenser

  A repulsive potential energy should be a positive one

Using the data provided on the webvista site in the file marked vdw.txt, try to develop a mathematical equation for the vdW potential we discussed in class, U(x), that best fits the data

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd