Calculating an average [was Re: Summary of loops]
From: Anthony Borla (ajborla_at_bigpond.com)
Date: 02/22/05
- Next message: Paul: "J2ME questions?"
- Previous message: Daniel Tahin: "Re: Help Running Java Ap"
- In reply to: claradona_at_hotmail.com: "Summary of loops"
- Next in thread: Daniel Tahin: "Re: Calculating an average [was Re: Summary of loops]"
- Reply: Daniel Tahin: "Re: Calculating an average [was Re: Summary of loops]"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 22 Feb 2005 11:12:42 GMT
<claradona@hotmail.com> wrote in message
news:1109068051.789292.213810@g14g2000cwa.googlegroups.com...
> Hi,
>
> I am stumped here. Been stuck doing this program and
> cant seem to debug the errors! Can someone pls help me?
> How do I calculate the totals of the computation in a loop
> and later display those averages as a summary outside the
> loop?
>
> much help is appreciated.
>
Mmm ! This question seems familiar ;) !!! Here's a very rough example:
double sum = 0.0;
for (int i = 0; i < MAX_ITERATIONS; i++)
{
...
sum += ...;
...
}
double average = sum / i;
// Display the average, and whatever else ...
// ...
You're likely to learn much more if you try to solve the problem yourself.
I hope this helps.
Anthony Borla
- Next message: Paul: "J2ME questions?"
- Previous message: Daniel Tahin: "Re: Help Running Java Ap"
- In reply to: claradona_at_hotmail.com: "Summary of loops"
- Next in thread: Daniel Tahin: "Re: Calculating an average [was Re: Summary of loops]"
- Reply: Daniel Tahin: "Re: Calculating an average [was Re: Summary of loops]"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|