Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Need help with Functions, ASAP!

Need help with Functions, ASAP!

Scheduled Pinned Locked Moved C#
tutorialcsharphelplearning
23 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • realJSOPR realJSOP

    Oh wait! If you'll give me your email address, I'll send you all my code for either your approval, or a list of ambiguous hints and criticisms about where I might have gone wrong before I check it in to TFS. Oh yeah, don't forget to include a lecture on the evils of asking a question on CodeProject. You know - so we don't foster dependency and laziness.

    ".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

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #13

    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.

    realJSOPR 1 Reply Last reply
    0
    • L Lost User

      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.

      realJSOPR Offline
      realJSOPR Offline
      realJSOP
      wrote on last edited by
      #14

      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

      L 1 Reply Last reply
      0
      • U User 13745651

        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)

        realJSOPR Offline
        realJSOPR Offline
        realJSOP
        wrote on last edited by
        #15

        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. -

        L B 2 Replies Last reply
        0
        • realJSOPR realJSOP

          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

          B Offline
          B Offline
          BillWoodruff
          wrote on last edited by
          #16

          John 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

          1 Reply Last reply
          0
          • realJSOPR realJSOP

            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

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #17

            So does the rest of the thread.

            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.

            realJSOPR 1 Reply Last reply
            0
            • realJSOPR realJSOP

              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, 2013

              B Offline
              B Offline
              BillWoodruff
              wrote on last edited by
              #18

              John 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

              1 Reply Last reply
              0
              • realJSOPR realJSOP

                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. -

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #19

                Now I'm amazed :) :thumbsup:

                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.

                realJSOPR 1 Reply Last reply
                0
                • L Lost User

                  So does the rest of the thread.

                  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.

                  realJSOPR Offline
                  realJSOPR Offline
                  realJSOP
                  wrote on last edited by
                  #20

                  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

                  1 Reply Last reply
                  0
                  • L Lost User

                    Now I'm amazed :) :thumbsup:

                    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.

                    realJSOPR Offline
                    realJSOPR Offline
                    realJSOP
                    wrote on last edited by
                    #21

                    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

                    1 Reply Last reply
                    0
                    • realJSOPR realJSOP

                      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. -

                      B Offline
                      B Offline
                      BillWoodruff
                      wrote on last edited by
                      #22

                      John Simmons / outlaw programmer wrote:

                      ... all methods technically return a value, whether it's void or some other type

                      A 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

                      1 Reply Last reply
                      0
                      • realJSOPR realJSOP

                        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

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #23

                        Yes. The "good samaritan" law should apply. Just don't move them.

                        "(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups