DATA604_Discussion_Week_3

Dilip Ganesan

Problem 3.5.17

  1. Walther has a roadside produce stand where he sells oats, peas, beans and barley. He buys these products at per-pound wholesale prices of, respectively, $1.05, $3.17, $1.99 and $0.95; he sells them at per-pound retail prices of, respectively, $1.29, $3.76, $2.23 and $1.65. Each day the amount demanded (in pounds) could be as little as zero for each product, and as much as 10, 8, 14 and 11 for oats, peas, beans and barley, respectively; he sells only whole-pound amounts, no partial pounds. Assume a discrete uniform distribution for daily demand for each product over its range; assume as well that Walther always has enough inventory to satisfy all demand. The summer selling season is 90 days, and demand each day is independent of demand on other days. Create a spreadsheet simulation that will, for each day as well as for the whole season, simulare Walther total cost, total revenue and total profit.
# Loading Wholesale Prices for Oats, Peas, Beans and Barley
whole_oats = 1.05
whole_peas = 3.17
whole_beans = 1.99
whole_barle = 0.95

# Loading Retail Prices for Oats, Peas, Beans and Barley
retail_oats = 1.29
retail_peas = 3.76
retail_beans = 2.23
retail_barley = 1.65

# Demand Range.
demand_oats = seq(0,10)
demand_peas = seq(0,8)
demand_beans = seq(0,14)
demand_barley = seq(0,11)

# Sample of each demand for 90 days 
oats_90_sam = sample(demand_oats,90,replace=TRUE)
peas_90_sam = sample(demand_peas, 90, replace = TRUE)
beans_90_sam = sample(demand_beans, 90, replace=TRUE)
bar_90_sam = sample(demand_barley,90,replace = TRUE)

# Calculation of Cost Price, Selling Price and Profit
cost_price_day = oats_90_sam * whole_oats +
                 peas_90_sam * whole_peas +
                 beans_90_sam * whole_beans +
                 bar_90_sam * whole_barle


selling_price_day = oats_90_sam * retail_oats +
                  peas_90_sam * retail_peas +
                  beans_90_sam * retail_beans +
                  bar_90_sam * retail_barley

profit_per_day = selling_price_day - cost_price_day 

# Final Result in Data Frame.
finaldf = data.frame("Oats" = oats_90_sam,"Peas" = peas_90_sam,
                     "Beans"= beans_90_sam, "Barley"=bar_90_sam, 
                     "Cost Price" = cost_price_day, "Selling Price" 
                     = selling_price_day, "Profit" = profit_per_day)
knitr::kable(finaldf)
Oats Peas Beans Barley Cost.Price Selling.Price Profit
0 1 13 9 37.59 47.60 10.01
8 2 10 2 36.54 43.44 6.90
9 4 7 1 37.01 43.91 6.90
6 1 3 0 15.44 18.19 2.75
10 2 13 7 49.36 60.96 11.60
9 7 13 2 59.41 70.22 10.81
7 2 11 5 40.33 49.33 9.00
2 8 11 8 56.95 70.39 13.44
10 5 13 6 57.92 70.59 12.67
1 8 14 1 55.22 64.24 9.02
6 3 0 7 22.46 30.57 8.11
5 7 4 5 40.15 49.94 9.79
2 0 1 7 10.74 16.36 5.62
5 4 5 3 30.73 37.59 6.86
3 7 3 0 31.31 36.88 5.57
3 3 6 8 32.20 41.73 9.53
10 1 11 11 46.01 59.34 13.33
3 3 4 6 26.32 33.97 7.65
10 6 3 10 44.99 58.65 13.66
4 7 3 1 33.31 39.82 6.51
1 4 13 3 42.45 50.27 7.82
8 1 14 10 48.93 61.80 12.87
8 4 10 5 45.73 55.91 10.18
9 8 4 1 43.72 52.26 8.54
1 2 9 1 26.25 30.53 4.28
7 3 0 10 26.36 36.81 10.45
1 5 4 1 25.81 30.66 4.85
3 2 2 6 19.17 25.75 6.58
9 0 9 11 37.81 49.83 12.02
7 8 9 5 55.37 67.43 12.06
10 3 2 2 25.89 31.94 6.05
1 3 5 2 22.41 27.02 4.61
6 7 11 0 50.38 58.59 8.21
6 1 13 11 45.79 58.64 12.85
4 7 13 9 60.81 75.32 14.51
10 4 12 10 56.56 71.20 14.64
5 5 14 3 51.81 61.42 9.61
1 5 13 0 42.77 49.08 6.31
4 1 3 9 21.89 30.46 8.57
1 6 13 0 45.94 52.84 6.90
8 2 2 7 25.37 33.85 8.48
0 4 14 0 40.54 46.26 5.72
2 0 13 10 37.47 48.07 10.60
8 0 13 7 40.92 50.86 9.94
3 3 10 3 35.41 42.40 6.99
3 6 5 8 39.72 50.78 11.06
1 6 14 10 57.43 71.57 14.14
0 0 0 1 0.95 1.65 0.70
5 1 3 4 18.19 23.50 5.31
3 1 9 11 34.68 45.85 11.17
0 8 1 6 33.05 42.21 9.16
0 0 0 8 7.60 13.20 5.60
10 6 4 6 43.18 54.28 11.10
8 2 10 8 42.24 53.34 11.10
8 6 8 0 43.34 50.72 7.38
4 8 10 9 58.01 72.39 14.38
5 6 0 8 31.87 42.21 10.34
0 7 12 7 52.72 64.63 11.91
4 5 6 10 41.49 53.84 12.35
10 4 0 2 25.08 31.24 6.16
4 0 11 2 27.99 32.99 5.00
9 6 5 1 39.37 46.97 7.60
8 2 2 0 18.72 22.30 3.58
1 1 2 8 15.80 22.71 6.91
1 6 6 3 34.86 42.18 7.32
4 8 0 10 39.06 51.74 12.68
9 7 1 11 44.08 58.31 14.23
5 3 14 0 42.62 48.95 6.33
0 7 8 3 40.96 49.11 8.15
3 0 6 3 17.94 22.20 4.26
0 8 8 11 51.73 66.07 14.34
9 5 2 11 39.73 53.02 13.29
2 0 2 4 9.88 13.64 3.76
8 6 12 3 54.15 64.59 10.44
10 7 7 2 48.52 58.13 9.61
10 2 11 9 47.28 59.80 12.52
9 6 10 1 49.32 58.12 8.80
1 7 14 6 56.80 68.73 11.93
9 3 0 3 21.81 27.84 6.03
4 2 8 6 32.16 40.42 8.26
5 7 11 4 53.13 63.90 10.77
0 5 9 2 35.66 42.17 6.51
7 4 3 1 26.95 32.41 5.46
1 8 12 0 50.29 58.13 7.84
9 6 8 11 54.84 70.16 15.32
5 2 0 9 20.14 28.82 8.68
7 5 14 8 58.66 72.25 13.59
4 6 14 3 53.93 63.89 9.96
2 0 9 7 26.66 34.20 7.54
7 6 12 2 52.15 61.65 9.50
# Summation Data Frame
summationdf = data.frame("Total Cost Price" = sum(finaldf$Cost.Price),
                   "Total Selling Price" = sum(finaldf$Selling.Price),
                   "Total Profit" = sum(finaldf$Profit))

knitr::kable(summationdf)
Total.Cost.Price Total.Selling.Price Total.Profit
3434.29 4249.73 815.44