From e66a6d38e05d3c4f738ca546d30bc28baa62e1e2 Mon Sep 17 00:00:00 2001
From: cheeks <134818917+leftovertoast@users.noreply.github.com>
Date: Thu, 2 Jan 2025 11:46:49 -0500
Subject: [PATCH] Completed TestScoreApp Ch2-Ex2
---
murach/.idea/.gitignore | 3 +++
murach/.idea/kotlinc.xml | 13 +++++++++++++
murach/.idea/misc.xml | 6 ++++++
murach/.idea/modules.xml | 8 ++++++++
murach/.idea/murach.iml | 9 +++++++++
murach/.idea/vcs.xml | 6 ++++++
.../ch02_ex2_TestScore/bin/TestScoreApp.class | Bin 1770 -> 1882 bytes
.../ch02_ex2_TestScore/src/TestScoreApp.java | 14 +++++++++++---
8 files changed, 56 insertions(+), 3 deletions(-)
create mode 100644 murach/.idea/.gitignore
create mode 100644 murach/.idea/kotlinc.xml
create mode 100644 murach/.idea/misc.xml
create mode 100644 murach/.idea/modules.xml
create mode 100644 murach/.idea/murach.iml
create mode 100644 murach/.idea/vcs.xml
diff --git a/murach/.idea/.gitignore b/murach/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/murach/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/murach/.idea/kotlinc.xml b/murach/.idea/kotlinc.xml
new file mode 100644
index 0000000..9d6ea82
--- /dev/null
+++ b/murach/.idea/kotlinc.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/murach/.idea/misc.xml b/murach/.idea/misc.xml
new file mode 100644
index 0000000..639900d
--- /dev/null
+++ b/murach/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/murach/.idea/modules.xml b/murach/.idea/modules.xml
new file mode 100644
index 0000000..3f876e2
--- /dev/null
+++ b/murach/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/murach/.idea/murach.iml b/murach/.idea/murach.iml
new file mode 100644
index 0000000..d6ebd48
--- /dev/null
+++ b/murach/.idea/murach.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/murach/.idea/vcs.xml b/murach/.idea/vcs.xml
new file mode 100644
index 0000000..6c0b863
--- /dev/null
+++ b/murach/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/murach/eclipse/ex_starts/ch02_ex2_TestScore/bin/TestScoreApp.class b/murach/eclipse/ex_starts/ch02_ex2_TestScore/bin/TestScoreApp.class
index 55b5df5f0d16574e7c26e459bfb861ca587f615d..b679bd49f526448f89144880b4af924e398d2132 100644
GIT binary patch
delta 444
zcmXAjOHUJF6o#K~W;q8;4!S74ap1&F?Dt!9v$W
zxUv{5nCEtP)m^4sCe3HN%^u*M*|)cyI}sk5SI&rGpERyA5O+J>e=co93n!m
zm`$Bi-R6UCJ{#Mzl$W0Cdry5jUU)~%C*q0TFC^3T_OG{xyLCM}wN2Ekq$*{RUQ+MS
zXZCf29pITiI=`7>oHUbUm?1%t6FlK0B~I~-93kzja)x!<*r0>gbW$T7ZXY#ah+%O_
z%ADr{ie{d2QItiBWiE-bIn6AWxgza*X=Q{_v}Cj}##Qu`V5_+%N0;k@YQZ^_Ozm<*
qDdln;4rq0``Ip!M$86!C%V$cu-G%jFJV?renP~2DC08w#?g;Ykdv9eGT6CU6;K7hTk
zA(6rd@Da4qQr|%xV{tQQW^T@WudSag?#p-M8Ax*Y=-wEvUpU=NhH+gtK2%men4_Le
z3J!VwWe$2X6cu;zoKD!?I%Qp28(y~cleK7-6|ujm8_iX#Cl}`q`+CH__N`#y73-O<
z+e0d*-|bMuy){(0>nPLJc6|Ty7Oq8V)iFB~4%!V;I^hYJWdeH1lfLp(pocPj?9tCY
zQ4Z;)LX1-eXcBGyU(N(s>4KD)WC}%yBGW_~Aigw`zY;kw6$dXV6
vAImaxSP@e@#t+G1Y=@ju%8>|i*<@9A25YQK^~#+sc_ntFbA@=K-C+Ww|;(
diff --git a/murach/eclipse/ex_starts/ch02_ex2_TestScore/src/TestScoreApp.java b/murach/eclipse/ex_starts/ch02_ex2_TestScore/src/TestScoreApp.java
index 7d7b4ec..651c1bf 100644
--- a/murach/eclipse/ex_starts/ch02_ex2_TestScore/src/TestScoreApp.java
+++ b/murach/eclipse/ex_starts/ch02_ex2_TestScore/src/TestScoreApp.java
@@ -15,7 +15,7 @@ public class TestScoreApp {
Scanner sc = new Scanner(System.in);
// get a series of test scores from the user
- while (testScore <= 100) {
+ while (testScore != 999) {
// get the input from the user
System.out.print("Enter score: ");
String input = sc.nextLine();
@@ -24,12 +24,20 @@ public class TestScoreApp {
// accumulate score count and score total
if (testScore <= 100) {
scoreCount = scoreCount + 1;
- scoreTotal = scoreTotal + testScore;
+ scoreTotal = scoreTotal + testScore;
+ }
+ else if (testScore >100) {
+ System.out.println("Invalid entry; not counted.");
+ continue;
+
}
}
// display the score count, score total, and average score
- double averageScore = (double) scoreTotal / scoreCount;
+ double averageScore = 0.0;
+ if(scoreCount > 0) {
+ averageScore = (double) scoreTotal / scoreCount;
+ }
String message = "\n"
+ "Score count: " + scoreCount + "\n"
+ "Score total: " + scoreTotal + "\n"