java - Averaging the values in while loop -


so have public accessor method called gettseconds , have called in while loop below 20 times:

int =0; double sum = 0; double average =0; while (i < 20) {         call.read();         sum = sum + call.getseconds();         system.out.println(sum);         average = sum / 10.0; } 

so called read 20 times , calculate how long took read file each time , average total time.but keep getting last time average instead of actual average.

i enticed change more - lets keep as possible of original - want this?

double sum = 0; double average =0; (int i=0; < 20; i++) {   call.read();   sum = sum + call.getseconds(); } average = sum / 20.0; system.out.println(average); 

note original while (i < 20) - condition true, in effect run forever. maybe had different intentions - in case, please more clear.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -