Question
computer simulation i need histogram graph to plotting the results in a histogram to check if answer is correct based on the question and c
computer simulation
i need histogram graph to plotting the results in a histogram to check if answer is correct based on the question and c code below i dint 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(n)
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(n)
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
{
// 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;
}
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