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 55b5df5..b679bd4 100644 Binary files a/murach/eclipse/ex_starts/ch02_ex2_TestScore/bin/TestScoreApp.class and b/murach/eclipse/ex_starts/ch02_ex2_TestScore/bin/TestScoreApp.class differ 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"