Answer:
Explanation:
The following code is written in Java and like requested prompts the user for a number to continue or a letter to exit. Then loops and keeps adding all of the numbers to the sum variable and adding 1 to the count for each number entered. Finally, it prints the sum and the average using printf and the variables.
import java.util.Scanner;
class Examine1 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int sum = 0;
int count = 0;
System.out.println("Enter a number to continue or a letter to exit.");
while(in.hasNextInt()) {
System.out.println("Enter a number:");
sum += in.nextInt();
count += 1;
}
System.out.printf("The sum is %s.%n", sum);
System.out.printf("The average is %s.", (sum / count));
}
}