import java.util.Scanner;
public class TestScoreApp
{
public static voice main(String[] args)
{
// display operational message
System.out.println("Please enter test scores that range from 0 to 100.");
System.out.println("To end the program enter 999.");
System.out.println(); // print a blank line
// initialize variables and create a Scanner object
double scoreTotal = 0.0;
int scoreCount = 0;
int testScore = 0;
Scanner sc = new Scanner(System.in);
// get a series of test scores from the user
while (testscore <= 100)
{
// get the input from the user
System.out.print("Enter score: ");
testScore = sc.nextInt();
// accumulate score count and score total
if (testScore <= 100)
{
scoreCount = scoreCount + 1;
scoreTotal = scoreTotal + testScore;
}
}
// display the score count, score total, and average score
double averageScore = scoreTotal / scoreCount;
String message = "\n"
+ "Score count: " + scoreCount + "\n"
+ "Score total: " + scoreTotal +
"\n"
+ "Average score" + averageScore +
"\n";
System.out.println(message);
}
}
*******************************************************
output:
Please enter test scores that range from 0 to 100.
To end the program enter 999.
Enter score: 90
Enter score: 80
Enter score: 75
Enter score: 999
Score count: 3
Score total: 245.0
Average score: 81.66666666666667
Press any key to continue..._