```java import java.util.Scanner; public class AverageCalculator { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); // Prompt the user to enter the number of elements System.out.print("Enter the number of elements: "); int numElements = scanner.nextInt(); // Create an array to store the numbers double[] numbers = new double[numElements]; // Prompt the user to enter each number and store them in the array System.out.println("Enter " + numElements + " numbers:"); for (int i = 0; i < numElements; i++) { System.out.print("Enter number " + (i + 1) + ": "); numbers[i] = scanner.nextDouble(); } // Calculate the sum of all numbers in the array double sum = 0; for (double num : numbers) { sum += num; } // Calculate the average double average = sum / numElements; // Print the sum and average System.out.println("Average of the numbers: " + average + " and the sum is: " + sum); // Close the scanner scanner.close(); } } ```