From e142e1afc253b9e4b271b4058f04606a1a751a8c Mon Sep 17 00:00:00 2001 From: Muhammad Saleem Chachar <88135749+Muhammad-Saleem-Ch@users.noreply.github.com> Date: Mon, 16 Oct 2023 23:05:44 -0700 Subject: [PATCH] Update Average.java --- Java/Average.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Java/Average.java b/Java/Average.java index 41776cbf..09c4811b 100644 --- a/Java/Average.java +++ b/Java/Average.java @@ -1,13 +1,13 @@ public class Average { public static void main(String[] args) { double[] numArray = { 45.4, 67.6, -45.4, 20.33, 33.1, 45.4 }; - double sum = 0.0; + double count = 0.0; for (double num: numArray) { - sum += num; + count += num; } - double average = sum / numArray.length; + double average = count / numArray.length; System.out.format("The average is: %.2f", average); } }