I have recently started programming in C - - using the BACI compiler. I have come across a program which is giving me a hard time with the functions.
1. A caterer provides cakes and muffins to a number of bakeries 2. When an order for cakes is received this order may be despatced with a similar order for cakes from another bakery 3. Similarly when an order for muffins is received this order may be despatced with a similar order for muffins from another bakery 4. If a batch (cakes or muffins) is being made, an order for the other food must wait 5. There are three odd-numbered bakeries who order bakes: c(1), c(3), c(5) 6. There are four even-numbered bakeries who order muffins m(2), m(4), m(6), m(8)
7. Food orders arrive in random order at the caterer: c(1), m(4), m(2), c(3) etc 8. An order is added to the food batch if it does not exceed the food batch size.
Maximum batch for cakes = 3
Maximum batch for muffins = 4
9. If there is a mixed set of orders,cakes and muffins, priority is given to cakes 10. A waiting order has the same priority as other orders of the same food type. 11. Selection of a waiting order from a bakery is on a random basis.
My code so far
int cakes_in = 0;
int cakes_out = 0;
int muffins_in = 0;
int muffins_out =0;
const int Max_Numb_Cakes = 3;
const int Max_Numb_Muffins = 4;
semaphore mutex;
semaphore cakes;
semaphore muffins;
int order_and_make_cakes()
{
}
int order_make_muffins()
{
}
int change_order_status()
{
}
main()
{
cobegin {cout << "orders are complete" << endl; }
}
I would very much like to write the functions to make the program run.If you have time please provide any input you might have. I am not an experienced programmer so if you could provide any comment with the functions i would greatly appreciate it.Thank you.
Comments
:
: Maximum batch for cakes = 3
: Maximum batch for muffins = 4
:
: My code so far
:
: int cakes_in = 0;
: int cakes_out = 0;
: int muffins_in = 0;
: int muffins_out =0;
:
: const int Max_Numb_Cakes = 3;
: const int Max_Numb_Muffins = 4;
:
: semaphore mutex;
: semaphore cakes;
: semaphore muffins;
:
: int order_and_make_cakes()
: {
:
: }
:
: int order_make_muffins()
: {
:
: }
:
: int change_order_status()
: {
:
: }
:
: main()
: {
: cobegin {cout << "orders are complete" << endl; }
: }
:
: I would very much like to write the functions to make the program run.If you have time please provide any input you might have. I am not an experienced programmer so if you could provide any comment with the functions i would greatly appreciate it.Thank you.
:
What is a "semaphore"?
What is "cobegin"?
I've never used that compiler but I have used c.
give more detail about the compiling problem and any error messages you see.
There is no need to explain the question when all you want is someone to look over your code to find the bug that prevents it from compiling.
[b]use the CODE stylecode to paste your code.!!![/b]
too many people don't bother reading the stylecodes at the bottom of the reply page.