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