From 2e0f4134609e99aeef6e93ce4ef9dd5242840f30 Mon Sep 17 00:00:00 2001 From: 86150 <86150@hunnu.edu.cn> Date: Mon, 11 May 2026 17:03:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0W7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- W7/ScoreCalculateorBefore.java | 15 +++++++++++++++ W7/ScoreCalculator.class | Bin 0 -> 1817 bytes W7/ScoreCalculatorAfter.java | 31 +++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 W7/ScoreCalculateorBefore.java create mode 100644 W7/ScoreCalculator.class create mode 100644 W7/ScoreCalculatorAfter.java diff --git a/W7/ScoreCalculateorBefore.java b/W7/ScoreCalculateorBefore.java new file mode 100644 index 0000000..24fae75 --- /dev/null +++ b/W7/ScoreCalculateorBefore.java @@ -0,0 +1,15 @@ +public class ScoreCalculateorBefore { + public static void main(String[] args) { + int sum = 0; + int count = 0; + BufferedReader br = new BufferedReader(new FileReader("scores.txt")); + String line; + while ((line = br.readLine()) != null) { + sum += Integer.parseInt(line); + count++; + } + br.close(); + double average = (double) sum / count; + System.out.println("Average score: " + average); + } +} diff --git a/W7/ScoreCalculator.class b/W7/ScoreCalculator.class new file mode 100644 index 0000000000000000000000000000000000000000..67ab4899333d020363b59d84b2747a13d3910533 GIT binary patch literal 1817 zcmaJ>OIsUN7=BMKoG?rq2-lQbYH1~CiFm6f&{|R=sa$Gn3uRqGDUNc}vZc0FoZ zifS%FbllMKCPo>0t71#$ZL2K2N2a$)f37Di&ttL_+J^MzDU;Zc2~eL3%-cHdC?vyn-Aj;6?<#nv z6-W1)@EpTEQs#o4+7=blNCk3Bt=o0W80RQ3#7jznc~L3XE5fshiAdfyNH%e$o`BLN z)g>9K!n7#c=;}pm)63L*$rI(Rc~SHIIp(RsCaxTd=XK!go0=`zb*C)V4I$C~>saH8 zEDD>pZO`=_QJa_Erfs0v$Tc!`l7c9xluS?NV)%-5Q?vrc zEdNpwW9n9AQ!IwBiR&51v7MB<<1`vl>jar^dQ1r2-IfmNC7_yi8T6uMNhe`4EP~D8J>CxzVZ^SD~Yy4TslPi!p#G8u4E&>;aYz(@-up$Og;;-{o_Bg z(H9s_MvibDI6!*;_z&_N-$!3I68z}dXfl$F9^k!X 0) { + double average = (double) sum / count; + System.out.println("Average score: " + average); + } else { + System.out.println("No valid scores found."); + } + } +} \ No newline at end of file