Answered step by step
Verified Expert Solution
Question
1 Approved Answer
computer simulation i need histogram graph to based in the results from the code below a histogram to check if answer is correct based on
computer simulation
i need histogram graph to based in the results from the code below a histogram to check if answer is correct based on the question and c code below so you need to run the code see the results plot it in the histogram graph and send it to me i dont want c code i need histogram graph plz everyone sending me codes
A baker is trying to figure out how many dozens of bagels to bake each day. Customers order a number of dozens bagels each. Bagels sell for 8.40 TL per dozen. They cost 5.80 TL. per dozen to make. All bagels not sold at the end of the day are sold at half price to a local grocery store.
Based on a long-run simulation, how many dozen (to the negrest dozen) bagels should be baked each day for given probability distributions p(r) and g(r) rethosenting the pm for the number of customers per day, and the number of dozens cach customer buys?
You are asked to assume one of the options given below:
(a) p(n) and q(r) are uniformly
#include
#include
#include
#define w 55
#define selling_price_per_dozen 8.4
#define cost_per_dozen 5.8
// Function to generate a random value from the probability distribution p
int generate_customers()
{
// Generate a random value between 11 and 50 inclusive
return 11 + rand() % (w - 30);
}
// Function to generate a random value from the probability distribution q
int generate_dozens_per_customer()
{
// Generate a random value between 1 and 10 inclusive
return 1 + rand() % 55;
}
int main()
{
// Seed the random number generator with the current time
srand(time(NULL));
// Initialize the total profit to 0
float total_profit = 0;
// Run the simulation for 1000 days
for (int i = 0; i
(b) p(n) and q(n) are given as p(n)={101,0,n=11,12,,10otherwise,q(n)={55n,0.n=1,2,,10otherwise. Cilivestupeniu{
// Generate the number of customers and the number of dozens per customer
int customers = generate_customers();
int dozens_per_customer = generate_dozens_per_customer();
// Calculate the total number of bagels sold
int total_bagels_sold = (customers * dozens_per_customer) * 12;
// Calculate the total revenue
float total_revenue = total_bagels_sold * selling_price_per_dozen;
// Calculate the cost of making the bagels
float cost_of_making_bagels = total_bagels_sold * cost_per_dozen;
// Calculate the profit for the day
float profit = total_revenue - cost_of_making_bagels;
// Add the profit for the day to the total profit
total_profit += profit;
}
// Calculate the average profit over the simulation
float average_profit = total_profit / 1000;
// Print the average profit
printf("Average profit: %.2f TL ", average_profit);
return 0;
}
for example like this histogram
(thats not related with the question just to show you)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started