Re: Get the average value ?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Ok, so I take it you do not have to write the code to fetch the data, no? So what kind of thing is the data in? An array? a datagrid? what? Point is you need to look up how to reference the values in that thing.

Then, write out the program / algorithm / strategy in english. Refine the english until you can substitue real Csharp code for the english statements. You know how calculate average; write out the steps in english. Hint. There's going to be a loop where you successively get values one at a time from your "data storage thing" and add them up.

No one ever writes a program by writing the first line of Csharp, then the second, third, ... in order until done. You must first have an algorithm, or strategy, or whatever you want to call it, for solving the problem. Write that down in english statements. Even experienced programmers don't skip the first step - develop a strategy (aka algorithm) for solving the problem. But experience allows us to often skip the "write it in english part." You should not skip this part. Sometimes when I'm stuck I resort to writing it out and darned if it doesn't help every time!

You'll probably be skipping around, refining different pieces here and there; not strictly in top-to-bottom order. That's OK. In fact that's good.

Final hint. You know that the code bits you need to solve this problem were presented in class (you did go to class, didn't you?). Review your book and notes!!!!!

On 2006-10-24 14:18:45 -0500, Jon Skeet [C# MVP] <skeet@xxxxxxxxx> said:

<jesper_lofgren@xxxxxxxx> wrote:
I need to write a function to calculate the average value from a coupe
of parameters from database.

Question 1

(value) (people that answer the specific value)
[1] 5
[2] 21
[3] 67
[4] 233
[5] 348
Any ideas would be very welcome.

Well, how far have you got, and which bit are you stuck on?


.



Relevant Pages

  • Re: "Sorting" assignment
    ... If you only learn the beautiful side of programming, ... elegance and beauty from the fact that we developed this algorithm ... The insertion sort can be illustrated and is ... English grammar, apparently, than many English speakers, a noun phrase ...
    (comp.programming)
  • Re: Help with S.A.M.
    ... As English is not my first language, so could someone please help me ... if the text-to-speech algorithm is messing ... For the Votrax line, the SC-01 and the SSI-263 did reasonably ... well after I respelled pizza as "peetsa". ...
    (comp.sys.apple2)
  • Re: Fermats Last theorem short proof
    ... interesting "algorithm." ... The problem is language and ... In English "better method" is what you ... is there any free web bage that shows the proof. ...
    (sci.math)
  • Re: pattern equality test?
    ... >> when I found the bugs in my algorithm. ... I like explanations of algorithms better than unexplained ... > after all it's supposed to be neither language nor OS-specific, ... code is less ambiguous than English. ...
    (comp.programming)
  • Re: Even the House of Lords recognised the fake conservationists
    ... about how you are stuck in a hovel on the outskirts of a giant slum ... Gosh, Angus. ... Try improving your English. ... That's a looney response. ...
    (uk.environment.conservation)