Answer:
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("How many numbers do you want to add?");
int numberOfNumbers = scanner.nextInt();
int arrayNumbers[] = new int[numberOfNumbers];
System.out.println("Enter " + numberOfNumbers + " numbers:\n");
for(int i = 0; i < numberOfNumbers; i++){
int addToArray = scanner.nextInt();
arrayNumbers[i] = addToArray;
}
int sum = 0;
for(int j = 0; j < arrayNumbers.length; j++){
sum+=arrayNumbers[j];
}
System.out.println("Sum: " + sum);
}
}
Explanation: