If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

What i am trying to do is, instead of it being a kids b'day party, let it be a normal adults party.

Let there be x number of invited guests. and lets imagine that 50% of all the guest consumer beer. and let beer come in kegs to feed 20 guests/keg.

I just need help with the last function in my code. where i want the number of invited guest to come from an earlier function (inv_guest) and then calculate the number of kegs of beer to be ordered. for example, if 123 people are invited, a total of 4 kegs of beer will be ordered; 3 for the first 60 and an extra 1 for the remaining 1 person.

What i am trying to do is, instead of it being a kids b'day party, let it be a normal adults party.

Let there be x number of invited guests. and lets imagine that 50% of all the guest consumer beer. and let beer come in kegs to feed 20 guests/keg.

I just need help with the last function in my code. where i want the number of invited guest to come from an earlier function (inv_guest) and then calculate the number of kegs of beer to be ordered. for example, if 123 people are invited, a total of 4 kegs of beer will be ordered; 3 for the first 60 and an extra 1 for the remaining 1 person.

First, don't name a variable the same as a function. You'll confuse yourself.

You're calling beer with an int reference called people that's set to 0. Why, isn't clear. Then you're passing people as a parameter to inv_guest, but never using it in that function. Then you multiply people (which is still set to 0, but the value returned by inv_guest, which doesn't make any sense.

It looks like you're guessing, or randomly coding without having a plan. Work out what steps you need to take before you try to write the code.

Re: An Event Planner

Re: An Event Planner

Originally Posted by rockx

GCDEF, could you help me please

I thought I did. I pointed out some places where you're going astray, but I can't give you the understanding that you lack. Go back and read the chapters on the basics in whatever book you're using and learn about functions, passing arguments to functions and declaring variable. You're missing some fundamentals that you need to understand.

Re: An Event Planner

As GCDEF stated, this looks exactly like code that has been made up 'on the hoof' as you go along. You really, really can't write programs like this. Not even us 'gurus' that have been coding since just about when computers were invented don't just sit down and 'write' a program. We first design the program. Determine what output is required, what input is necessary, what processing has to be undertaken. What is the high-level program 'flow'. What functions are required and their purpose, what parameters are required for these functions, what values do they return. For c++ programs, what objects are referenced by the program, how these objects are to represented as classes, what operations are required for the objects etc etc etc. When and only when all this design work has been undertaken do we then start to code the program from the design.

I would strongly suggest that before you code further that you first produce a design for the program. Once you have the design that you are happy with then code your program from the design. You know then how the program is supposed to work (as you have the design) so if you have issues with writing the code we can provide guidance. If (when!) your progam doesn't work first time you can then debug your code against the design to see where its behavior deviates from that expected.

All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

I just need help with the last function in my code. where i want the number of invited guest to come from an earlier function (inv_guest) and then calculate the number of kegs of beer to be ordered. for example, if 123 people are invited, a total of 4 kegs of beer will be ordered; 3 for the first 60 and an extra 1 for the remaining 1 person.

Re: An Event Planner

Note also that the while statement in your input function can also be simplifed to

} while (choice < 1 || choice > 5);

Also, you don't need the global variable num_guest as you are passing the number of guests as a parameter to beer_cal. invite_guest doesn't need a parameter as it returns the number of guests.

All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!