Need help with Functions, ASAP!
-
At least he is honest about it and providing a comment to explain it. You'd be usually the first to sneak something into the solution to get the kid in trouble :D A downvote just costs some points, and we have enough to spend.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
It's not about the points. It's about down-voting an answer the is CORRECT, because that reflects on ME.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
So I very recently started learning my first coding language at college, which is C#, i have an assignment in for Tuesday and cant for the life of me figure out how to complete one of the tasks it asks of me. The task is as follows: "Write example program code that demonstrates the use of a function that calculates and returns the mean average of 5 values that are passed to it." If anyone could walk me through what to do or give me some example code as to how they would approach this task then that would be most appreciated. (I'm using VisualStudio)
So here we are. I provided an answer (two, in all actuality), and my answers were down-voted because some pompous ass decided that you didn't deserve the answer I provided. I didn't provide any guidance, because I don't know if you're TRULY serious about being a programmer, or just taking an elective course to fulfill diploma requirements. If you're serious, you gotta learn to THINK like a programmer. That means taking a project, breaking it down into logical steps, writing psuedo-code, and then writing actual code. I'm assuming your instructor taught you about functions, and how they work. Actually, they're called METHODS, and all methods technically return a value, whether it's
void
or some other type. Methods also (optionally) accept one or more parameters. So let's break down your requirement into easily consumable requirements: 0) write a program that demonstrate the use of a function (method) 1) the function calculates an average of five values 2) the function returns the calculated average Notice that there is no specification regarding WHERE the function gets the five values. This means you can set up a globally accessible collection of values, or pass parameters to the function. It's your choice how to proceed here. Once you've decided which way you're going to provide the consumable data (the five values), you can craft your method prototype accordingly. The body of the method has two processes - calculate the average of the values provided, and return the resulting average. It's really just that simple (if you were in class for the instructor's guidance regarding the assignment, and paying attention). If you want definitions for any of the nomenclature I've used above, google is your friend. You certainly shouldn't expect any specific help here, because after all, this is a homework question, and Bill simply won't let that happen. ---------------- Now, that too way too much f*ckin time to type. I don't really care if you are serious about being a programmer, or that this is even homework. I'm not your instructor, and it took LESS of my VALUABLE time to simply "give you the codez" than to give you most of the lesson you should have gotten from your instructor.".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - -
It's not about the points. It's about down-voting an answer the is CORRECT, because that reflects on ME.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
BillWoodruff wrote:
If we provide code to people that helps them avoid/shirk their homework, we are degrading the educational process, and contributing to the OP's failure to learn and grow: we are fostering dependency and laziness.
Down-voting CORRECT answers is bullsh|t, Bill, regardless of whether or not YOU believe that the user should have gotten said answer.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013John Simmons / outlaw programmer wrote:
Down-voting CORRECT answers is bullsh|t, Bill
I take the responsibility I believe is involved in being a Mentor on this site seriously. You continue to be someone I respect technically, and whose many contributions to this site, I have learned from. sincerely, Bill
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
-
Should we get your approval before answering questions from now on?
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013John Simmons / outlaw programmer wrote:
Should we get your approval before answering questions from now on?
No ! :wtf:
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
-
So here we are. I provided an answer (two, in all actuality), and my answers were down-voted because some pompous ass decided that you didn't deserve the answer I provided. I didn't provide any guidance, because I don't know if you're TRULY serious about being a programmer, or just taking an elective course to fulfill diploma requirements. If you're serious, you gotta learn to THINK like a programmer. That means taking a project, breaking it down into logical steps, writing psuedo-code, and then writing actual code. I'm assuming your instructor taught you about functions, and how they work. Actually, they're called METHODS, and all methods technically return a value, whether it's
void
or some other type. Methods also (optionally) accept one or more parameters. So let's break down your requirement into easily consumable requirements: 0) write a program that demonstrate the use of a function (method) 1) the function calculates an average of five values 2) the function returns the calculated average Notice that there is no specification regarding WHERE the function gets the five values. This means you can set up a globally accessible collection of values, or pass parameters to the function. It's your choice how to proceed here. Once you've decided which way you're going to provide the consumable data (the five values), you can craft your method prototype accordingly. The body of the method has two processes - calculate the average of the values provided, and return the resulting average. It's really just that simple (if you were in class for the instructor's guidance regarding the assignment, and paying attention). If you want definitions for any of the nomenclature I've used above, google is your friend. You certainly shouldn't expect any specific help here, because after all, this is a homework question, and Bill simply won't let that happen. ---------------- Now, that too way too much f*ckin time to type. I don't really care if you are serious about being a programmer, or that this is even homework. I'm not your instructor, and it took LESS of my VALUABLE time to simply "give you the codez" than to give you most of the lesson you should have gotten from your instructor.".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - -
And I already had that rep, so no harm, no foul. You should have seen the stuff I didn't post...
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
With what? I did what Bill should have done if he was truly concerned with the OP learning something. Instead, he chose to treat everyone that provided real answers like they were 12-year-olds, and scold us for just giving the OP what he wanted.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
So here we are. I provided an answer (two, in all actuality), and my answers were down-voted because some pompous ass decided that you didn't deserve the answer I provided. I didn't provide any guidance, because I don't know if you're TRULY serious about being a programmer, or just taking an elective course to fulfill diploma requirements. If you're serious, you gotta learn to THINK like a programmer. That means taking a project, breaking it down into logical steps, writing psuedo-code, and then writing actual code. I'm assuming your instructor taught you about functions, and how they work. Actually, they're called METHODS, and all methods technically return a value, whether it's
void
or some other type. Methods also (optionally) accept one or more parameters. So let's break down your requirement into easily consumable requirements: 0) write a program that demonstrate the use of a function (method) 1) the function calculates an average of five values 2) the function returns the calculated average Notice that there is no specification regarding WHERE the function gets the five values. This means you can set up a globally accessible collection of values, or pass parameters to the function. It's your choice how to proceed here. Once you've decided which way you're going to provide the consumable data (the five values), you can craft your method prototype accordingly. The body of the method has two processes - calculate the average of the values provided, and return the resulting average. It's really just that simple (if you were in class for the instructor's guidance regarding the assignment, and paying attention). If you want definitions for any of the nomenclature I've used above, google is your friend. You certainly shouldn't expect any specific help here, because after all, this is a homework question, and Bill simply won't let that happen. ---------------- Now, that too way too much f*ckin time to type. I don't really care if you are serious about being a programmer, or that this is even homework. I'm not your instructor, and it took LESS of my VALUABLE time to simply "give you the codez" than to give you most of the lesson you should have gotten from your instructor.".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. -John Simmons / outlaw programmer wrote:
... all methods technically return a value, whether it's
void
or some other typeA method with the 'void specification does not return anything: if the compiler encounters a 'return statement in a 'void Method followed by any .NET Type instance, it will throw an error. Of course, the 'return flow of control statement ... by itself ... is valid.
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
-
BillWoodruff wrote:
If we provide code to people that helps them avoid/shirk their homework, we are degrading the educational process, and contributing to the OP's failure to learn and grow: we are fostering dependency and laziness.
Down-voting CORRECT answers is bullsh|t, Bill, regardless of whether or not YOU believe that the user should have gotten said answer.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013