Java

Average of all array elements Using Java

[crayon-5a2bba714dae4557121185/] Output Average is : 4.857142857142857 Discussion To limit the digits after decimal use : ‘DecimalFormat’ Class or System.out.format() or String.format or System.out.printf() e.g. DecimalFormat newDecimalFormat = new DecimalFormat(“#:00”); newnumber = newDecimalFormat.format(whateverYourNumberIs); It will give you 4.85 according for above Read more…

By faltutech, ago