calculate average java

Solutions on MaxInterview for calculate average java by the best coders in the world

showing results for - "calculate average java"
Fabiana
03 Jun 2018
1Just some minor modification to your code will do (with some var renaming for clarity) :
2
3double sum = 0; //average will have decimal point
4
5for(int i=0; i < args.length; i++){
6   //parse string to double, note that this might fail if you encounter a non-numeric string
7   //Note that we could also do Integer.valueOf( args[i] ) but this is more flexible
8   sum += Double.valueOf( args[i] ); 
9}
10
11double average = sum/args.length;
12
13System.out.println(average );
queries leading to this page
find average method in javacalculating average in java results in integer valuemath average javahow to calculate average in javajava find averagefind average using variable in javaaverage in javahow to work out average in javaaverage calculator javafind average in javawhat to find average of integer in java 8get average value javajava average calculatorhow to compute the average num 2cber in java calculate average in javahow to get the average in javahow to do average in javajava code to find averagedo an average in javafind average using method in javahow to use average in javajava get averagejava how to calculate averageget average javawrite program to find average in javafind average number in javaaverage of numbers in javacalculating average in javaaverage java mathfind average number of method in java calculate mean javahow to take the average in javajava get average code java calculate avgmath average in javahow to find average in java programmingfind average javacalculating average javahow to get average in javajava average of numbershow to calculate below value of average using javaaverage number in javawrite a method to find average in javahow to find the average javacalculate average object javajava program to find averagehow to find average value in javaget average method javajava find the averagecalculate the average in javacalculate the average javajava code to fing average using functionaverage of variable in javajava calcunate avghow to calcualte average javajava calculate int averagecode for average in javacalculate average javahow to find average javaaverage num in javacalculate average percentage in java find the average in javahow to get average number in java how to calculate average using javahow to find the average in javafind average number in java methodjava get a averageaverage calculator in javamath java averageeasy to find average in javahow to find average in javajava integer averageaverage java programhow calculate average javaaverage om javaaverage javajava how to find the average of resultsjava compute averagejava get average numberjava average findercode to find the average in javajava function to find averagejava math averagemath average javajava calculate averageaverage definition in javajava average methodjava code for to find the averagejava averagehow to find average of a number javacalculate average java