Completed TestScoreApp Ch2-Ex2
This commit is contained in:
parent
eec228a630
commit
e66a6d38e0
3
murach/.idea/.gitignore
generated
vendored
Normal file
3
murach/.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
13
murach/.idea/kotlinc.xml
generated
Normal file
13
murach/.idea/kotlinc.xml
generated
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Kotlin2JsCompilerArguments">
|
||||
<option name="moduleKind" value="plain" />
|
||||
</component>
|
||||
<component name="Kotlin2JvmCompilerArguments">
|
||||
<option name="jvmTarget" value="1.8" />
|
||||
</component>
|
||||
<component name="KotlinCommonCompilerArguments">
|
||||
<option name="apiVersion" value="2.0" />
|
||||
<option name="languageVersion" value="2.0" />
|
||||
</component>
|
||||
</project>
|
||||
6
murach/.idea/misc.xml
generated
Normal file
6
murach/.idea/misc.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
8
murach/.idea/modules.xml
generated
Normal file
8
murach/.idea/modules.xml
generated
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/murach.iml" filepath="$PROJECT_DIR$/.idea/murach.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
9
murach/.idea/murach.iml
generated
Normal file
9
murach/.idea/murach.iml
generated
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
6
murach/.idea/vcs.xml
generated
Normal file
6
murach/.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
Binary file not shown.
@ -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();
|
||||
@ -25,11 +25,19 @@ public class TestScoreApp {
|
||||
if (testScore <= 100) {
|
||||
scoreCount = scoreCount + 1;
|
||||
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"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user